if(condition)
{
statement(s); /*to be executed, on condition being true*/
}
| this expression | is true if |
|
x == y x != y x < y x > y x <= y x >= y |
x is equal to y x is not equal to y x is less than y x is greater than y x is less than or equal to y x is greater than or equal to y |
Fig- Flow Diagram of if statement
#include <stdio.h>
int main()
{
int number;
printf("Enter an integer: ");
scanf("%d", &number);
// Test expression is true if number is less than 0
if (number < 0)
{
printf("You entered %d.", number);
}
printf("The if statement is easy.");
return 0;
}
Enter an integer: -2 You entered -2. The if statement is easy.