Lecture 04 C++ Conditional Statement (ES 1EE)
Lecture 04 C++ Conditional Statement (ES 1EE)
if statement
• If statements in C++ is used to control the
program flow based on some condition, it's
used to execute some statement code block
if the expression is evaluated to true.
Otherwise, it will get skipped.
C++ Conditional • Syntax:
Statement • if(test_expression)
MICHAEL B. FRANCISCO, LPT, MIT • statement;
PROFESSOR
if statement if statement
• Comprasion Operators • Example 1:
• Less than (<)
• Greater than (>)
• Less than or equal to (<=)
• Greater than or equal to (>=)
• Equals (==)
• Not equals (!=)
10/9/2020
if statement if statement
• Example 2: • Example 3:
Problem 1 Problem 2
• Create a program that compute the
average grade of the student in C++ Subject.
Input the Name, Prelim, Midterm and Final
grade . If the average grade is greater than
or equal to 75, display “Passed!” and if not
display “Better Luck Next Time!”
10/9/2020
Problem 2 Problem 3
•Enter any integer number. If the
inputted integer number is less
than 50, display “The number is
too small.” otherwise, divide the
integer number by 5 times 2 and
display it.
Problem 3