- If statement define a block by curly braces {}.
- When the condition is true then the statement given in this block is executed.
if(condition)
{
/* Statements to be executed if condition is true */
}
- If the condition is false then skip the entire block to the compiler.
- If the if statement is used in the above example, then the program can be written as
#include <stdio.h>
int main()
{
int sudoAge = 22;
int bkAge = 21;
/* Taking decision which variable holds bigger value using if statement */
if(sudoAge > bkAge)
{
printf("sudo is elder\n");
}
return 0;
}
- In the above example, a condition is used while using conditional operator.
- If the age of Sudo is greater than Bk then the printf () statement given in the if statement will execute.
- But if not, then this statement will not be executed.
sudo is elder
No comments:
Post a Comment
Please do not any spam link in Comment Box