Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

CSC425 Introduction to Computer Programming

Lab 5: Selection Structure

Task 2: Suppose that x, y, and z are int variables, and x = 10, y = 15, and z = 20. Determine
whether the following expressions evaluate to true or false.

a. !(x > 10) 🡪 !(10>10), !(0), 1


b. x <= 5 || y < 15 🡪 10<=5 || 15<=15 0
c. (x != 5) && (y != z) 🡪 (10!=5) &&(15 !=20) 1
d. x >= z || (x + y >= z) 🡪 10>=20 || (10+15>=20) 1
e. (x <= y - 2) && (y >= z) || (z - 2 != 20) 🡪 (10 <=15-2) && (15 >=20) || (20-2 !=20) 1

Task 8: Write a program that reads an integer and determines and prints whether it is odd or
even. (Hint: use modulus operator)

Task 11: Write a pseudocode and a complete C++ program that prompts the user to enter the
reading of API. The program is able to check the air quality based the API table and prints an
appropriate message to the user.
Task 12: Write a complete C++ program for the following problem statement using suitable
control structure.
Calculate and display the new price (after discount deduction) of a car using the following
table

Task 13: Write a C++ program for a simple calculator using switch selection structure. Your
program should be able to read two numbers from user. (+, -, *, /)

You might also like