Documente Academic
Documente Profesional
Documente Cultură
DECISIONS
Objectives:
If-else
Switch
Boolean Operator
Arithmetic Expressions:
(a) If (No else branch)
In C++ if statements are used to implement a decision. When the condition is fulfilled the
statements mentioned in the body of if are executed.
2: Write a program to input two integers and find out whether the first integer is greater or
the second.
C++ has a selection operator of the form
The value of that expression is either value1 if the test passes or value2 if it fails.
4: Write a program to find out the grade of student based on the average score. The grade is
calculated as
If score is greater than or equal to 90, the grade is A
If score is greater than or equal to 80, the grade is B
If score is greater than or equal to 70, the grade is C
If score is greater than or equal to 60, the grade is D
If score is less than 60, the grade is F
LAB TASK:
1: Write a program to input an integer from the user, check if it is an even number or odd
number and print the message.
2: Write a program to find the roots of a quadratic equation. The roots are calculated as
Note: Submit the lab report of these two lab tasks in the next lab.