+ 1
Why does second condition not execute
6 Answers
+ 5
Because the first condition is true. All other else statements will be skipped after a condition is found to be true
+ 2
"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"
+ 2
https://code.sololearn.com/cy6OIsZ3cEQD/?ref=app
Thanks for the help I also have query on the above code.
+ 2
//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.
+ 2
Keep coding. Keep asking. Keep learning. That is why we mention it.
+ 1
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);
}