Professional Documents
Culture Documents
Control Statement/Decision Making Statement
Control Statement/Decision Making Statement
If
If else
If else if ladder
Nested if
Switch
1. IF Statement
Syntax : if(condition)
Statement;
After if statement;
Flow Chart:
Program:
i. Code:
Output:
Output:
For True Value
iii. Code: 1
Output:
1.
2.
Code : 2
Output
1.
2.
Code: 3
Output: 1
Output: 2
2. IF else Statement
Syntax:
if(condition)
Else
Flow Chart
Program:
Q- WAP to show that whether a person is eligible to vote or not on the basis of his/her age. If the person’s age is
greater than 18, then he/she is eligible, otherwise not.
Output 1.
Output 2
3. Nested IF Statement
Syntax:
If(condition1)
{
If (condition2)
If(condition3)
……..
Syntax 2
If(condition1)
If(condition2)
Or else
Else
Q- WAP that will receive age and salary from the user on the basis of following statements, show salary increment
(a) if age is 50 or more and salary is less than 60000, then Salary Increment by 10000
(b) If if age is 50 or more and salary is more than 60000, then salary increment by 5000
Output:1
Output: 2
4. If else if ladder statement
Syntax:
If(condition1)
Statement 1;
Else if(condition2)
Statement 2;
Else if(condition 3)
Statement 3;
……..
…….
………
Else if(condition n)
Statement n;
Else
Default statement;
Flow Chart:
Proogram:
Output: 2
Output: 3
Output : 4