Computer Programming Lab # 3
Computer Programming Lab # 3
Statements
Objectives:
To be familiar with Relational & Logical Operators
To understand the programming knowledge using Selection Statements (if, if-else, if-else ladder, Nested
if-else and Switch)
Task Titles:
1. Display the largest among three numbers using if else statement?
2. Check whether a number is even or odd?
3. Check the greater of two numbers using ternary operator?
4. Write a program where you print you take a number from the user if the number is
greater than 2 and then print your name and registration number 2 times or else print only
1 time.
5. Write a program that asks a number and test the number whether it is multiple of 5 or not,
divisible by 7 but not by eleven. (all three conditions should match)
6. Check whether the entered character is vowel or consonant?
7. Write a program that takes the weekday number as input from user and print the day
name of week
E.g., Print Monday if weekday number is equal to 1. Similarly, check condition for all 7
days and print the corresponding day name. Print an error message if an invalid number is
entered.
8. Write a C++ program to enter month number between (1-12) and print number of days in
month.
9. Write a program to calculate and print the Electricity bill of a given customer. The
customer id and unit consumed by the user should be taken from the keyboard and
display the total amount to pay to the customer. The charges are as follow:
Unit Charge/unit
Up to 199 @1.20