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

Conditional Statements Exercise

1. C++ program to find maximum between two numbers using if else.


Example Input Output
Input num1: 10 Maximum = 20
Input num2: 20
2. C program to find maximum between three numbers using if else.
Example Input Output
Input num1: 10 Maximum = 20
Input num2: 20
Input num3: 15
3. C program to check whether a number is positive, negative or zero
Example Input Output
Input number: 23 23 is positive
4. C program to check whether a number is divisible by 5 and 11 or not
Example Input Output
Input number: 55 Number is divisible by 5 and 11
5. C program check whether a number is even or odd
Example Input Output
Input number: 10 10 is even number
6. C program to check Leap Year
Example Input Output
Input year: 2004 2004 is leap year
7. C program to check vowel or consonant
Example Input Output
Input character: a 'a' is vowel
8. C program to count total number of notes in given amount
Example Input Output
Input amount: 538 Total number of notes:
100: 1,
50:0
10:3
5:1
1:3
9. C program to enter week number and print day of week
Example Input Output
Input week number: 1 Monday
10. C program to check whether triangle is valid or not if angles are given
Example Input Output
Input first angle: 60 The triangle is valid
Input second angle: 30
Input third angle: 90
11. C program to check whether triangle is valid or not if sides are given
Example Input Output
Input first side: 7 The triangle is valid
Input second side: 10
Input third side: 5
12. C program to check whether triangle is equilateral, scalene or isosceles
Example Input Output
Input first side: 30 Triangle is equilateral
Input second side: 30 triangle
Input third side: 30
13. C program to find all roots of a quadratic equation
Example Input Output
Input a: 8 Root1: 0.80
Input b: -4 Root2: -0.30
Input c: -2
14. C program to calculate profit or loss
Example Input Output
Input cost price: 1000 Profit: 500
Input selling price: 1500
15. Write a C program to input electricity unit charge and calculate the total electricity bill
according to the given condition:
For first 50 units ETB 0.50/unit
For next 100 units ETB 0.75/unit
For next 100 units ETB 1.20/unit
For unit above 250 ETB 1.50/unit
An additional surcharge of 20% is added to the bill.

You might also like