0

How to print if and else both statements in same condition

In if else either the if or the else statement is executed but what if we put such condition that both if and else is executed simultaneously....so what would be that condition??

9th May 2020, 8:42 AM
Madhav Malaviya
Madhav Malaviya - avatar
5 Answers
+ 3
That would be either no condition, or both statements after the if condition. if the sun is shining I go out else I stay at home You cannot go out and stay at home at the same time.
9th May 2020, 5:12 PM
Tashi N
Tashi N - avatar
+ 2
If and else are meant to treat *different* conditions. Can you clarify what you are talking about?
9th May 2020, 8:56 AM
HonFu
HonFu - avatar
+ 1
In if else either if or else is executed but what if we put such condition that both if and else is executed simultaneously....so what would be that condition??
9th May 2020, 9:16 AM
Madhav Malaviya
Madhav Malaviya - avatar
+ 1
Do you mean you want to ask for two conditions at the same time, effectively becoming one condition? That goes like this: if(sunIsShining&&notAWorkday) goForAWalk(); (You use && to create a double condition.)
9th May 2020, 5:39 PM
HonFu
HonFu - avatar
+ 1
I got my point thanks HonFu and Tashi N!
9th May 2020, 5:46 PM
Madhav Malaviya
Madhav Malaviya - avatar