condition statement

Post on 14-Feb-2017

11 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

In The Name of ALLAH, The Most Gracious, The Most Merciful.

Group Members

Minhaj Butt (0002)Daniyal Khan (0047)

Adeel Awan (0052)Syed Nasir Ali (0053)

Condition StatementCondition Statement are used to execute a set of statement

on some conditions. If the condition is true then the set

of statement are executed otherwise the body is skipped.

Types of Conditions Statement

There are three types of Condition Statement.

• If Statement.• If-else Statement.• Nested If-else Statement.

If StatementIf statement is conditional statement. It is use to execute a statement or a set of statement against a given condition. If given condition is true the assosiative statement will execute. It is used for one way decision making.

Syntax

If ( Condition )Statement;

ExampleIf (a==10)

Printf ( “your choice is ten” );

And

If (a>b)Printf ( “a is maximum” );

Flowchart of If Statement

If-else StatementIf-else statement is conditional statement. It is used for two way decision making. There is one condition and two decision. If given condition is true then first decision will execute and second will be ignored. If given condition is false then first decision will be ignored and the second decision will be executed.

Syntax

If (condition)Statement 1;

ElseStatement 2;

ExampleIf ( a > b )

Printf ( “a is maximum” );Else

Printf ( “b is maximum” );And

If ( percentage>=60 )Printf ( “pass” );

ElsePrintf ( “fail” );

Flowchart of If-else Statement

Nested If-else Statement

An If statement which is written within another if or if-else statement is called Nested if statement .

SyntaxIf ( Condition 1 )

Statement 1;Else

If (Condition2 )Statement 2;

ElseStatement 3;

Flowchart of Nested If Statement

top related