Why does second condition not execute | SoloLearn: Learn to code for FREE!


Why does second condition not execute

Help https://code.sololearn.com/cffQ5vFWz51o/?ref=app

4/3/2019 8:33:18 PM

Unemployed Visionary.

6 Answers

New Answer


Because the first condition is true. All other else statements will be skipped after a condition is found to be true


"else if" is only executed, when "if" is false. Since 10 is smaller than 20 and 10 is greater than 6 the "if" is true and no other statement in the "if"-statement are checked. Please use proper tags: Included the programming language in the tags. Do not use unneccessary tags like "help" and "asap"


https://code.sololearn.com/cy6OIsZ3cEQD/?ref=app Thanks for the help I also have query on the above code.


//sneeze //jay Thank you,guys for helping me out its quite generous of you. Regarding the double post.I am sorry as I am new to this forum,so I'm not familiar with the protocols. I respect your decision I will not do that again.


Keep coding. Keep asking. Keep learning. That is why we mention it.


Please start a new thread for every question if num==3 the code will executes continue; Continue jumps out of the while and does not decrease num-- So num stays 3 It comes in another iteration and the same repeats. Here you have created a infinite loops Personally I do not use continue because of this behaviour. You can do this with just for-loops, while-loops and if-statement if (num == 3) { num--; //decraese num before continue continue; } I do prefer this one if (num != 3) { printf("%d\n",num); }