C - If Statement

Learn C - C tutorial - C if statement - C examples - C programs
C If Statement - Definition and Usage
- In C- Programming the if statement is a conditional branching statement that is if the condition is satisfied the respective block of code is executed.

C Syntax
if (condition satisfy)
{
Statements are executed;
}
Sample coding - If statement
#include<stdio.h>
#include<conio.h>
void main()
{
int a=10,b=10;
if (a == b)
{
printf("a and b are equal");
}
getch();
}
C Code - Explanation

- Here we declare the variable a &b as “10” with its data type as integer.
- In this statement we check the value for the variable a&b which are equal or not, because if the condition is true the printf statement prints “a” and “b” are equal”..
Output :

- Here the value of the variable “a & b” are equal so “if” condition will be satisfied and the output print statement will be displayed as “a and b are equal”.