0

How to execute if and else condition at same time?

18th Aug 2017, 4:03 PM
thagallapally shiva teja
thagallapally shiva teja - avatar
11 Answers
+ 3
What are you trying to accomplish? By the nature of if / else, you want it to do one or the other, based upon those conditions. If you want it to execute the code for both, if either condition is true, then just use the OR operator. if(this || that) { do all of this; } I just realized you didn't specify what lang you're working with. My example is just pseudo for C oriented languages that uses that type of syntax. Same concept applies to most.
18th Aug 2017, 4:09 PM
AgentSmith
+ 1
You want it to check the condition or you want it to execute the code for both?
18th Aug 2017, 4:23 PM
AgentSmith
+ 1
we can execute in C if(printf("if")==0) printf(" if"); else printf(" else"); try this.
19th Aug 2017, 1:08 AM
thagallapally shiva teja
thagallapally shiva teja - avatar
+ 1
But why do you want to do that?
19th Aug 2017, 5:47 AM
Jonas Schröter
Jonas Schröter - avatar
+ 1
my friend asked me that question so I posted in this
19th Aug 2017, 9:28 AM
thagallapally shiva teja
thagallapally shiva teja - avatar
0
can you give one example ?
18th Aug 2017, 4:10 PM
thagallapally shiva teja
thagallapally shiva teja - avatar
0
i I mean that I want to execute both if and else at same time
18th Aug 2017, 4:17 PM
thagallapally shiva teja
thagallapally shiva teja - avatar
0
if(!printf("good")) { printf("good"); else{ printf("bad"); } this prints goodbad
18th Aug 2017, 4:25 PM
corejava
0
the code above is not executing in java it shows some error
18th Aug 2017, 4:27 PM
thagallapally shiva teja
thagallapally shiva teja - avatar
0
I want to execute for both
18th Aug 2017, 4:29 PM
thagallapally shiva teja
thagallapally shiva teja - avatar
0
Sorry but this is stupid and senseless.
18th Aug 2017, 7:22 PM
Jonas Schröter
Jonas Schröter - avatar