Professional Documents
Culture Documents
LAB 5-In Lab Tasks 1
LAB 5-In Lab Tasks 1
Learning Objectives
In today’s lab, you will practice;
1. Using one-way selection structure (if).
2. Using two-way selection structure (if/else).
3. Using multiple selection structure (switch).
Practice Questions
You can practice the following problems in this lab.
Task 1.1 Increment and Decrement Operators
Write a C++ program which prompts the user to enter an integer value, stores it into a variable
called ‘num’, evaluates the following expressions and displays results on screen.
num+5, num-3, (num+3) – 2, ((num+5)*2 / (num+3))
For performing addition and subtraction, you are allowed to use ONLY the increment and
decrement operators (both prefixing and postfixing are allowed). You must remember that
using increment/decrement operators changes the original value of a number. Indent your code
and include comments for improving the readability of your code. Your program should have
the following interface.
Enter a number : 20
20 + 5 = 25
20 – 3 = 17
(20 + 3)- 2 = 21
((20 + 5)*2 / (20 + 3)) = 2
Enter a value : 7
It is an odd digit.
Enter a value : H
It is an alphabet in UPPERCASE.
Enter a value : f
It is an alphabet in lowercase.
Enter a value : *
It is a special symbol.