0% found this document useful (0 votes)
142 views

List of Problem in Conditional Statement

The document lists 26 programming exercises involving if/else statements in C language. The exercises include programs to find the maximum of numbers, check number properties, determine triangle validity, calculate grades and bills, read input and display outputs. The exercises cover basic conditional logic and math operations on different data types.

Uploaded by

Haneesha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views

List of Problem in Conditional Statement

The document lists 26 programming exercises involving if/else statements in C language. The exercises include programs to find the maximum of numbers, check number properties, determine triangle validity, calculate grades and bills, read input and display outputs. The exercises cover basic conditional logic and math operations on different data types.

Uploaded by

Haneesha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

List of if...

else programming exercises


1. Write a C program to find maximum between two numbers.
2. Write a C program to find maximum between three numbers.
3. Write a C program to check whether a number is negative, positive or zero.
4. Write a C program to check whether a number is divisible by 5 and 11 or not.
5. Write a C program to check whether a number is even or odd.
6. Write a C program to check whether a year is leap year or not.
7. Write a C program to check whether a character is alphabet or not.
8. Write a C program to input any alphabet and check whether it is vowel or consonant.
9. Write a C program to input any character and check whether it is alphabet, digit or special
character.
10. Write a C program to check whether a character is uppercase or lowercase alphabet.
11. Write a C program to input week number and print week day.
12. Write a C program to input month number and print number of days in that month.
13. Write a C program to count total number of notes in given amount.
14. Write a C program to input angles of a triangle and check whether triangle is valid or not.
15. Write a C program to input all sides of a triangle and check whether triangle is valid or not.
16. Write a C program to check whether the triangle is equilateral, isosceles or scalene triangle.
17. Write a C program to find all roots of a quadratic equation.
18. Write a C program to calculate profit or loss.
19. Write a C program to input marks of five subjects Physics, Chemistry, Biology, Mathematics
and Computer. Calculate percentage and grade according to following:
Percentage >= 90% : Grade A
Percentage >= 80% : Grade B
Percentage >= 70% : Grade C
Percentage >= 60% : Grade D
Percentage >= 40% : Grade E
Percentage < 40% : Grade F
20. 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%
21. Write a C program to input electricity unit charges and calculate total electricity bill
according to the given condition:
For first 50 units Rs. 0.50/unit
For next 100 units Rs. 0.75/unit
For next 100 units Rs. 1.20/unit
For unit above 250 Rs. 1.50/unit
An additional surcharge of 20% is added to the bill
1. Write a C program to accept two integers and check whether they are equal
or not. Go to the editor
Test Data : 15 15
Expected Output :
Number1 and Number2 are equal
Click me to see the solution

2. Write a C program to check whether a given number is even or odd. Go to


the editor
Test Data : 15
Expected Output :
15 is an odd integer
Click me to see the solution

3. Write a C program to check whether a given number is positive or


negative. Go to the editor
Test Data : 15
Expected Output :
15 is a positive number
Click me to see the solution

4. Write a C program to find whether a given year is a leap year or not. Go to


the editor
Test Data : 2016
Expected Output :
2016 is a leap year.
Click me to see the solution

5. Write a C program to read the age of a candidate and determine whether it


is eligible for casting his/her own vote. Go to the editor
Test Data : 21
Expected Output :
Congratulation! You are eligible for casting your vote.
Click me to see the solution

6. Write a C program to read the value of an integer m and display the value
of n is 1 when m is larger than 0, 0 when m is 0 and -1 when m is less than
0. Go to the editor
Test Data : -5
Expected Output :
The value of n = -1
Click me to see the solution

7. Write a C program to accept the height of a person in centimeter and


categorize the person according to their height. Go to the editor
Test Data : 135
Expected Output :
The person is Dwarf.
Click me to see the solution

8. Write a C program to find the largest of three numbers. Go to the editor


Test Data : 12 25 52
Expected Output :
1st Number = 12, 2nd Number = 25, 3rd Number = 52
The 3rd Number is the greatest among three
Click me to see the solution

9. Write a C program to accept a coordinate point in a XY coordinate system


and determine in which quadrant the coordinate point lies. Go to the editor
Test Data : 7 9
Expected Output :
The coordinate point (7,9) lies in the First quadrant.
Click me to see the solution

10. Write a C program to find the eligibility of admission for a professional


course based on the following criteria: Go to the editor
Marks in Maths >=65
Marks in Phy >=55
Marks in Chem>=50
Total in all three subject >=180
or
Total in Math and Subjects >=140

Test Data :
Input the marks obtained in Physics :65
Input the marks obtained in Chemistry :51
Input the marks obtained in Mathematics :72
Expected Output :
The candidate is eligible for admission.
Click me to see the solution
11. Write a C program to calculate the root of a Quadratic Equation. Go to the
editor
Test Data : 1 5 7
Expected Output :
Root are imaginary;
No solution.
Click me to see the solution

12. Write a C program to read roll no, name and marks of three subjects and
calculate the total, percentage and division. Go to the editor
Test Data :
Input the Roll Number of the student :784
Input the Name of the Student :James
Input the marks of Physics, Chemistry and Computer Application : 70 80 90
Expected Output :
Roll No : 784
Name of Student : James
Marks in Physics : 70
Marks in Chemistry : 80
Marks in Computer Application : 90
Total Marks = 240
Percentage = 80.00
Division = First
Click me to see the solution

13. Write a C program to read temperature in centigrade and display a


suitable message according to temperature state below : Go to the editor
Temp < 0 then Freezing weather
Temp 0-10 then Very Cold weather
Temp 10-20 then Cold weather
Temp 20-30 then Normal in Temp
Temp 30-40 then Its Hot
Temp >=40 then Its Very Hot
Test Data :
42
Expected Output :
Its very hot.
Click me to see the solution
14. Write a C program to check whether a triangle is Equilateral, Isosceles or
Scalene. Go to the editor
Test Data :
50 50 60
Expected Output :
This is an isosceles triangle.
Click me to see the solution

15. Write a C program to check whether a triangle can be formed by the given
value for the angles. Go to the editor
Test Data :
40 55 65
Expected Output :
The triangle is not valid.
Click me to see the solution

16. Write a C program to check whether a character is an alphabet, digit or


special character. Go to the editor
Test Data :
@
Expected Output :
This is a special character.
Click me to see the solution

17. Write a C program to check whether an alphabet is a vowel or


consonant. Go to the editor
Test Data :
k
Expected Output :
The alphabet is a consonant.
Click me to see the solution

18. Write a C program to calculate profit and loss on a transaction. Go to the


editor
Test Data :
500 700
Expected Output :
You can booked your profit amount : 200
Click me to see the solution
19. Write a program in C to calculate and print the Electricity bill of a given
customer. The customer id., name and unit consumed by the user should be
taken from the keyboard and display the total amount to pay to the customer.
The charge are as follow : Go to the editor

Unit Charge/unit

upto 199 @1.20

200 and above but less than 400 @1.50

400 and above but less than 600 @1.80

600 and above @2.00

If bill exceeds Rs. 400 then a surcharge of 15% will be charged and the
minimum bill should be of Rs. 100/-

Test Data :
1001
James
800
Expected Output :
Customer IDNO :1001
Customer Name :James
unit Consumed :800
Amount Charges @Rs. 2.00 per unit : 1600.00
Surchage Amount : 240.00
Net Amount Paid By the Customer : 1840.00

Click me to see the solution

20. Write a program in C to accept a grade and declare the equivalent


description : Go to the editor

Grade Description
E Excellent

V Very Good

G Good

A Average

F Fail

Test Data :
Input the grade :A
Expected Output :
You have chosen : Average
Click me to see the solution

21. Write a program in C to read any day number in integer and display day
name in the word. Go to the editor
Test Data :
4
Expected Output :
Thursday
Click me to see the solution

22. Write a program in C to read any digit, display in the word. Go to the editor
Test Data :
4
Expected Output :
Four
Click me to see the solution

23. Write a program in C to read any Month Number in integer and display
Month name in the word. Go to the editor
Test Data :
4
Expected Output :
April
Click me to see the solution

24. Write a program in C to read any Month Number in integer and display the
number of days for this month. Go to the editor
Test Data :
7
Expected Output :
Month have 31 days
Click me to see the solution

25. Write a program in C which is a Menu-Driven Program to compute the


area of the various geometrical shape. Go to the editor
Test Data :
1
5
Expected Output :
The area is : 78.500000
Click me to see the solution

26. Write a program in C which is a Menu-Driven Program to perform a simple


calculation. Go to the editor
Test Data :
10
2
3
Expected Output :
The Multiplication of 10 and 2 is: 20
Click me to see the solution

You might also like