if Statement in C Language
This is the most powerful and simple form of decision control statement. If statement is always used with a condition and responsible for modifying the flow of execution of a program. In this form, a set of statements inside the body of If condition are executed only if the condition evaluates result as true. The syntax for if statement is as follows:-
if(condition)
{
Statements ;
}
#include<stdio.h> #include<conio.h> void main() { int no; printf("Enter a number"); scanf("%d",&no); if(no<0) { printf("%d is a negative number",&no); } getch(); }
Flow Chart of if Statement
If statement is used to execute a particular area of code if and only if the condition is true otherwise code does not executed in given block.
ADVERTISEMENT