Nested of 'if ' means one ' if ' is enclosed with in another ' if '. In nested if, every ' if ' have an else statement.
Syntax-:
if(condition)
if(condition)
statement-1;
else
statement-2;
elsestatement-3;
}
ads
Example-:
#include<stdio.h>
#include<conio.h>
main()
{ int a=0,b=0,c=0;
printf("Enter the value of a,b,c);
scanf("%d %d %d",&a,&b,&c);
if(a>b)
{if(a>c)
printf("\n %d is largest",a);
else
printf("\n %d is largest",c);
}
else if(b>c)
printf("\n %d is largest",b);
else
printf("\n %d is largest",c);
getch();
}
output-: Enter the value of a,b,c 10
15
22
22 is largest
ads
subscribe tech programiz to get notification of latest blogs
ReplyDelete