Monday, 17 September 2012

If statement

The simplest if structure involves a single executable statement. Execution of the statement occurs only if the condition is true.
Syntax:
if (condition)
    statement;

Flow chart:








Example:

#include<stdio.h>
#include<conio.h>
void main ()
{
int marks;
clrscr();
{
printf("Enter your marks:");
scanf("%d",&marks);
if(marks >=50)
printf("CONGRATULATIONS...!!! you have passed.");
}
getch();
}

Limitation of if statement
The statement(s) are executed if the condition is true; if the condition is false nothing happens in other words we may say it is not the effective one. Instead of it we use if-else statements etc.

No comments:

Post a Comment