If Else If Programs
If Else If Programs
2. 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.
3. Write a C program to accept the height of a person in centimeters and categorize the person according to their
height.
Test Data : 135
Expected Output :
The person is Short.
5. Write a C program to accept a coordinate point in an XY coordinate system and determine in which quadrant the
coordinate point lies.
Test Data : 7 9
Expected Output :
The coordinate point (7,9) lies in the First quadrant.
6. Write a C program to determine eligibility for admission to a professional course based on the following criteria:
Eligibility Criteria : Marks in Maths >=65 and Marks in Phy >=55 and Marks in Chem>=50 and Total in all three
subject >=190 or Total in Maths and Physics >=140
Sample I/O:
Input the marks obtained in Physics :65 Input the marks obtained in Chemistry :51 Input the marks obtained in
Mathematics :72 Total marks of Maths, Physics and Chemistry : 188 Total marks of Maths and Physics : 137 The
candidate is not eligible.
Expected Output :
The candidate is not eligible for admission.
7. Write a C program to read the roll no and marks of three subjects and calculate the total, percentage and Class
division.
Sample I/O:
Test Data :
Input the Roll Number of the student :784
Input the marks of Physics, Chemistry and Computer Application : 70 80 90
Expected Output :
Roll No : 784
Marks in Physics : 70
Marks in Chemistry : 80
Marks in Computer Application : 90
Total Marks = 240
Percentage = 80.00
Division = First class with distinction.
8. Write a C program to read temperature in centigrade and display a suitable message according to the temperature
state below:
Test Data :
42
Expected Output :
Its very hot.
Test Data :
50 50 60
Expected Output :
This is an isosceles triangle.
Test Data :
k
Expected Output :
The alphabet is a consonant.
11. Write a program in C to calculate and print the electricity bill of a given customer. The customer ID and unit
consumed by the user should be captured from the keyboard to display the total amount to be paid to the customer.
Unit Charge/unit
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
800
Expected Output :
Customer IDNO :1001
unit Consumed :800
Amount Charges @Rs. 2.00 per unit : 1600.00
Surchage Amount : 240.00
Net Amount Paid By the Customer : 1840.00