0% found this document useful (0 votes)
102 views16 pages

If - Else Ladder

The document discusses if-else if ladders which help users decide among multiple options. If statements are executed top-down and the first true condition triggers its associated statement, bypassing the rest. If no conditions are true, the final else statement executes. An example uses instructions like L, R, U, D to navigate a grid and find a hidden gift based on if statements.

Uploaded by

Adharsh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views16 pages

If - Else Ladder

The document discusses if-else if ladders which help users decide among multiple options. If statements are executed top-down and the first true condition triggers its associated statement, bypassing the rest. If no conditions are true, the final else statement executes. An example uses instructions like L, R, U, D to navigate a grid and find a hidden gift based on if statements.

Uploaded by

Adharsh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 16

DECISION MAKING -

BRANCHING

1/77
SELECTION STRUCTURE: IF-
ELSE IF LADDER

• if-else-if ladder helps user decide from


among multiple options.
• if statements are executed from the top down.
• As soon as one of the conditions controlling
the if is true, the statement associated with that
if is executed, and the rest of the else-if ladder
is bypassed.
• If none of the conditions is true, then the final
else statement will be executed.
SELECTION STRUCTURE: IF-
ELSE IF LADDER
FLOWCHART
EXAMPLE 1
EXAMPLE 2

 Today is Ram’s birthday and he is looking forward to his


gift. As usual, the gift is hidden and Ram has to follow a
sequence of 5 instructions to reach it.Initially, Ram is
standing in the cell (0,0) of a two-dimensional grid. If we
denote Ram’s current cell by (x, y), each instruction can be
as follows:
 'L' means to go left, i.e. to the cell (x,y-1)
 'R' means to go right, i.e. to the cell (x,y+1)
 'U' means to go up, i.e. to the cell (x-1,y)
 'D' means to go down, i.e. to the cell (x+1,y)
 Find the cell (xg,yg) which contains the hidden gift.
MCQS
}

Answer:b=300 c=200
Answer: x=10 y=10
Answer: Until my evil purse was filled
Answer:200
Answer:Pilots are on strike
Answer: Error –Expected ‘(‘ before x
Answer: j=0
Answer: Stoned(binary equivalents will be
different)
Answer: x and y are equal
Comparing a float with integer is internally taken to be
comparison between two floats (int will be casted to
float)

You might also like