Professional Documents
Culture Documents
(I) If Statement
(I) If Statement
Statements ;
Example :
/* elegible to vote */
#include<stdio.h>
Int main()
int age ;
scanf(“%d”,&age);
if(age>=18)
return 0;
General format
if (condition)
statement 1;
else
statement2;
#include<stdio.h>
int main()
int number;
printf("enter number");
scanf("%d",&number);
if(number%2==0)
else
return 0;
General format
if (codition1)
if(condition2)
statement1;
else
Statement2;
else
statement 3;
Statement n;
#include<stdio.h>
int main()
int a,b,c,big;
printf("\n enter three numbers :");
scanf("%d%d%d",&a,&b,&c);
if(a>b)
if(a>c)
big=a;
else
big=c;
else
if(b>c)
big=b;
else
big=c;
return 0;
}
Else if ladder
if(condition1)
statement1;
else if (condition2)
statement2;
else if(condition3)
statement3;
else if (condition n )
statement n ;
else
default statement ;
statement X
/* to find lower case or upper case letter or to check whether athe character is not an alphabetic
character */
#include<stdio.h>
int main()
{char a ;
scanf("%c",&a);
else
return 0 ;