Monday, August 31, 2020

9.3.3 else if

  • If you want to put another condition between if and else, then you can do it by defining another if block.
Syntax


if(expression)
{
//execute your code
}
else if(expression n)
{
//execute your code
}
else
{
//execute your code
}



EXAMPLE :-


if(sudoAge > bkAge)
{
printf("Sudo is elder");
}
/* one more condition checked using else if */
else if(bkAge > sudoAge)
{
printf("Bk is elder");
}
else
{
printf("Both are equal");
}





No comments:

Post a Comment

Please do not any spam link in Comment Box