If Else Statement - C Tutorial

If Else Statement

If else statements in C is also used to control the program flow based on some condition, only the difference is: it’s used to execute some statement code block if expression is evaluated to true, otherwise executes else statement code block.

Syntax of if else statement

if(boolean_expression)
{
   //executes when the boolean expression is true
}
else
{
   //executes when the boolean  expression is false
}

C Program to Check Whether a Number is Even or Odd using If Else

#include<stdio.h>
int main()
{
	int num;
	printf("Enter the Number :");
	scanf("%d",&num);
	if(num%2==0)
		printf("%d is Even Number",num);
	else
		printf("%d is Odd Number",num);
	return 0;
}
Output - C Program to Check Whether a Number is Even or Odd using If Else
Enter the Number :13                                                                                                  
13 is Odd Number