if Statement in C

If Statement in C:
This is a conditional statement used in C to check condition or to control the flow of execution of statements. This is also called as ‘decision making statement or control statement.’ The execution of a whole program is done in one direction only.

Syntax:
if(condition)
{
statements;
}

In above syntax, the condition is checked first. If it is true, then the program control flow goes inside the braces and executes the block of statements associated with it. If it returns false, then program skips the braces. If there are more than 1 (one) statements in if statement then use { } braces else it is not necessary to use.

Program :

/*  Program to demonstrate if statement.
Creation Date : 09 Nov 2010 02:36:27 AM
Author : www.technoexam.com [Technowell Web Solutions, INDIA] */

#include <stdio.h>
#include <conio.h>
int main(void)
{
	int a;
	a=5;
	clrscr();
	if(a>4)
		printf("\nValue of A is greater than 4 !");
	if(a==4)
		printf("\n\n Value of A is 4 !");
	getch();
	return 0;
}

Output :
Value of A is greater than 4 !

Leave A Comment

Your email address will not be published. Required fields are marked *