saving . . . saved else termination has been deleted. else termination has been hidden .
else termination
How else is working even if i terminate it by semicolon?

#include <stdio.h>
int main()
   int a,b,c;
   printf("Enter the value of a,b and c \\n");
   if(a>b && a>c)
       printf("a is greater than b and c \\n");
   else if(b>a && b>c)
       printf("b is greater than a and c\\n");
       printf("c is greater than a and b\\n");
return 0;

C-and-Cpp If-And-Else-If-statement 05-06 min 30-40 sec 29-02-20, 12:56 p.m. HarryKaur


in the above code what we have code after else; statement it will execute always because after else we put ; so the if-else part is completed 

so irrespective  of a,b,c values we will get "c is greater than and b"
29-02-20, 2:18 p.m. ravi.10541
thanku sir
29-02-20, 3:35 p.m. HarryKaur

Login to add comment

A semicolon after the else indicates an empty else clause.
if (something) {
} else;

is the same as:
if(something) {
} else {

29-02-20, 2:49 p.m. bhaskar76

for the above mentioned program the actual procedure is:


While executing this type of a question, if condition1 is false control automatically transfer to will not touch else keyword.....

you can visualize this with turbo C Interpreter (Press f7 Key continuously)
29-02-20, 2:58 p.m. itt513

Log-in to answer to this question.