> if else statement in c ~ Online tutorial

if else statement in c

If else statement

syntax

If(test expression)

{

True block statement(s)

}

Else

{

False block statement(s)

}

Statement –x

If the test epression can be executed first if it is true then true block can be executed

immediately following if statement are executed otherwise false statement are executed if neither case they sattement x can be executed


Eg:

If(code==1)

Boy=boy+1;

Else

Girl=girl+1;

If the code==1 can be executed first if it is true then boy is one incremented can be executed
otherwise false statement are executed that is girl will be one incremented

Program:

Main()

{

Int n,boy,girl;

Printf(“enter the value”);

Scanf(“%d”,&n);

If(n==1)

{

Boy=boy+1;

printf("boy=%d",&boy);

Else

printf(girl%d",girl);

Girl=girl+1;

}

Getch();

}


output:

enter the value 1

boy=1

Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: