You are on page 1of 4

LAB MANUAL

LAB # 4
Conditional statement :-
The conditional operator is kind of similar to the if-else
statement as it does follow the same algorithm as of if-else
statement but the conditional operator takes less space and helps
to write the if-else statements in the shortest way possible.

Types :-
 if
 if-else
 if-else-if
 switch
 IF :-
An if-else statement controls conditional branching.
Statements in the if-branch are executed only if the condition
evaluates to a non-zero value (or true ). If the value of
condition is nonzero, the following statement gets executed,
and the statement following the optional else gets skipped.
 IF-ELSE :-
An if-else statement controls conditional branching.
Statements in the if-branch are executed only if
the condition evaluates to a non-zero value (or true). If the
value of condition is nonzero, the following statement gets
executed, and the statement following the
optional else gets skipped. Otherwise, the following
statement gets skipped, and if there's an else then the
statement following the else gets executed.

 IF-ELSE-IF :-
A common programming construct in C++ is the if-else-if
ladder, which is often also called the if-else-if staircase
because of its appearance.
 SWITCH :-
C++ provides a multiple-branch selection statement known
as switch. This selection statement successively tests the
value of an expression against a list of integer or character
constants. When a match is found, the statements
associated with that constant are executed.
STATEMENT # 1:-
Get three numbers as input from keyboard. Determine which one
is the largest of the three.

PROGRAM :-
STATEMENT # 2 :
Get an integer as input from keyboard. Determine whether it is even or
odd in nature.

PROGRAM :-
STATEMENT # 3 :
Get two numbers from user and tell that the first one is the multiple of
second or the second one is the multiple of first one.

PROGRAM :-

You might also like