> if statement in c ~ Online tutorial

if statement in c



The If Statement




Syntax

If(test expression)

{

Statement block;

}


Flow of data


The statement block may be singlesatement or group of statement .if the test expression is true

,the statement block is executed ,otherwise the statement block will be skipped and the execution will jump to the statement x

Eg:

If(category==sports)

{

Marks=marks+bonus;

}

Printf(“%f”,marks);

Program:

Main()

{

Int a,b,c,d;

Float ratio;

Printf(“enter the integer no”);

Scanf(“%d%d%d%d”,&a, &b, &c, &d);

If(c-d!=0)

{

Ratio=(float)(a+b)/float(c-d);

Printf(“%f”,ratio);

}

}

Output:

Enter the integer no

12

23

34

45

Ratio=-3.18




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: