Conditional Structured
1) Write a program which asks the user to input a no if user enters negative no the
program should output/print an error and exit.
2) Write a program to calculate the total expenses. Quantity and price per item are input
by the user and discount of 10% is offered if the expense is more than 5000.
3) Write a program that inputs name and 3 subject’s marks from the user, calculate
marks average if average is above 80 then program display message you are
outstanding.
4) Write a program which asks the user to input 2 numbers now determine which
number is greater and print the result.
5) Write a program which asks the user to input 3 numbers now determine which
number is greater and print the result.
6) Write a program that accept a value form the user, program find the absolute value
(Positive) of a number entered by the user
7) Write a program that input a year from the user and display the entered year id Leap
year or not.
8) Write a C++ program to check whether a character is alphabet or not.
9) Any integer is input by the user. Write a program to find out whether it is an odd
number or even number.
10) Write a C++ program that Input a number and check whether it is divisible by
both 5 and 11 or not
11) Write a program that inputs the name age of three persons, If the ages of Ali, Kashif
and Aslam are input by the user than determine and display the youngest of the them.
12) Program to check whether a given number is Armstrong number or not.
a. For example, 371 is an Armstrong number, since 3 x 3 + 7 x 3 + 1 x 3 = 371.
13) Write a program to check whether a triangle is valid or not, when the three angles of
the triangle are entered by the user. A triangle is valid if the sum of all the three
angles is equal to 180 degrees.
14) Write a program to determine whether the seller has made profit or incurred loss.
Also determine how much profit he made or loss he incurred. Cost price and selling
price of an item is input by the user.
15) Write a program that inputs salary and grade. It adds 70% bonus if the grade is
greater than [Link] adds 25% bonus if the grade is 17 or less and then display the total
salary.
16) Write a C program to input any character and check whether it is alphabet, digit or
special character.
17) Write a C program to check whether a character is uppercase or lowercase alphabet.
18) Write a program that contains an if statement that may be used to compute the area of
a square (area = side * side) or a triangle (area = * base * height) after prompting the
user to type the first character of the figure name (S or T).
19) Write a C program to input basic salary of an employee and calculate its Gross salary
according to following:
Basic Salary <= 10000 : HRA = 20%, DA = 80%
Basic Salary <= 20000 : HRA = 25%, DA = 90%
Basic Salary > 20000 : HRA = 30%, DA = 95%
20) Write a C program to input any alphabet and check whether it is vowel or consonant.
21) . Write a program to calculate the monthly telephone bills as per the following rule:
Minimum Rs. 200 for upto 100 calls.
Plus Rs. 0.60 per call for next 50 calls.
Plus Rs. 0.50 per call for next 50 calls.
Plus Rs. 0.40 per call for any call beyond 200 calls
22) Write a program that determines a student’s grade. The program will read three types
of scores (quiz, mid-term, and final scores) and determine the grade based on the
following rules:
if the average score =90% =>grade=A
if the average score >= 70% and <90% => grade=B
if the average score>=50% and <70% =>grade=C
if the average score<50% =>grade=F
23) The marks obtained by a student in 5 different subjects are input by the user. The
student gets a division as per the following rules:
Percentage above or equal to 60 - First division
Percentage between 50 and 59 - Second division
Percentage between 40 and 49 - Third division
Percentage less than 40 - Fail
Write a program to calculate the division obtained by the student.
24) Write a program that calculates the electricity bill. The rate of electricity per unit as
follows.
If the units consumed are <=100, then the cost is Rs. 5.5/- per unit.
If the units consumed are <100 and <=250, then the cost is Rs. 7.5/- per unit.
If the units consumed exceed <250, then the cost is Rs. 10.5/- per unit.
A line rent Rs. 50 is also added to the bill and surcharge of 7% extra if the bill
exceeded Rs. 1500/-.calculate the total bill.
25) Write a program that displays the following menu for a parking area.
Enter B for Bike
Enter C for car
Enter T for truck
The program inputs the type of vehicle and number of days to park the vehicle. It
finally displays the total charges for the parking according to the following.
Bike Rs. 300/- per day
Car Rs. 5000/- per day
Truck Rs. 10000/- per day
26) Any character is entered by the user; write a program to determine whether the character
entered is a capital letter, a small case letter, a digit or a special symbol. The following
table shows the range of ASCII values for various characters.
27) Characters 28) ASCII Values
29) A – Z 30) 65 – 90
31) a – z 32) 97 – 122
33) 0 – 9 34) 48 – 57
35) special symbols 36) 0 - 47, 58 - 64, 91 - 96, 123 – 127