The if-else statement is used to make decisions, where if a condition is true, then it will execute a block of code; if it isn’t true (else), then it will execute a different block of code.
if(marks == 97) {
// if marks are 97 then will execute this block of code
}
else {
// else it will execute this block of code
}
Below is the C program to demonstrate an if-else statement:
#include <stdio.h>
int main()
{
int a = 10;
if(a < 11)
{
printf("A is less than 11");
}
else
{
printf("A is equal to or "
"greater than 11");
}
return 0;
}
Output
A is less than 11