Barani Institute of Science Sahiwal: Assignment # 01
Barani Institute of Science Sahiwal: Assignment # 01
ASSIGNMENT # 01
Subjects:
ICT
Submitted by:
Hira Mehmood
Submitted to:
Hina Umbreen
Registration No:
20-BIS-2431
“Department of CS”
2
Contents
Syntax
if (condition) {
statement 1;
statement 2;
statement 3;
Here, the if-else statement comprises two parts, namely, if and else. If the condition is True
the if part is executed. However, if the condition is False, the else part is executed.
Syntax
The syntax of the if-else statements is
1 if (condition) // if part {
4
2 statement1;
3 statement2;
4 }
6 statement3;
Example
A code segment to determine the greater of two numbers
Syntax
if (condition1) {
statement1;
if(condition2)
statement2;
else
statement3; }
else
statement4;
Example
A code segment to determine the largest of three numbers