Computer Applications
Explain if-else-if construct
Input in Java
12 Likes
Answer
It is used when more than one condition are to be evaluated and only one of them is true.
The syntax of if-else-if construct is as follows:
if(condition 1)
Statement 1 //executed if condition 1 is true
else if(condition 2)
Statement 2 //executed if condition 2 is true
else
Statement 3 //executed if both conditions 1 and 2 are false
When 'condition 1' is 'True' then it will execute statement 1. In case 'condition 1' is false, the control will move to 'else if' part and will check 'condition 2'. If it is true, the control will execute 'Statement 2' otherwise it will execute 'Statement 3'.
Answered By
7 Likes
Related Questions
Distinguish between Syntax error and Logical error.
Explain if-else construct
Write a program to calculate and display the value of the given expression:
(a2+b2)/(a-b),when a=20, b=15Write a program to calculate the gross salary of an employee when
Basic Salary = Rs.8600
DA = 20% of Salary
HRA = 10% of Salary
CTA = 12% of the Salary.
Gross Salary = (Salary + DA + HRA + CTA)