Practice Questions for Midterm Exam practice
1. Tax Calculator
Create a program that:
• Takes the annual income from the user.
• Applies tax as follows:
o Income ≤ 300,000: No tax.
o Income > 300,000 and ≤ 700,000: 10% tax.
o Income > 700,000: 20% tax.
• Displays the income, tax rate, tax amount, and net income after tax.
2. Electricity Bill Calculator
Write a program to compute the electricity bill:
• Ask the user for the number of units consumed.
• Up to 100 units: Rs. 5/unit
• 101–300 units: Rs. 7/unit.
• Above 300 units: Rs. 10/unit.
• Add a flat Rs. 50 as a service charge to the bill.
• Display the total units consumed, total bill before discount, discount amount, and final bill
amount.
3. Restaurant Bill with Discounts
Write a program to calculate the bill at a restaurant:
• Ask the user for the bill amount.
• Ask the user if they are a loyalty program member (yes/no).
• If the amount exceeds Rs. 500, apply a 15% discount.
• If the amount exceeds Rs. 1000, apply an additional 5% discount (total 20%).
• Loyalty program members get an extra 10% discount on the final amount after applying
the above discounts.
• Add 10% service charge to the final discounted bill amount.
• Display the original bill amount, total discount applied, service charge, and the final
amount to pay.
4. Salary Calculator
Write a C program to calculate the monthly salary of an employee:
• Ask the user for the basic salary.
• Add a 20% house rent allowance (HRA) and a 10% medical allowance to the basic
salary.
• If the employee has completed 10 years of service, add a Rs. 5,000 loyalty bonus.
• Display the basic salary, total allowances, deductions, and final salary.
5. Shopping Discount Based on Online Shopping
Design a program that calculates an online shopping bill:
• Ask the user for the bill amount.
• Ask the user if they are a loyalty program member (yes/no).
• If the amount exceeds Rs. 500, apply a 15% discount.
• If the amount exceeds Rs. 1000, apply an additional 5% discount (total 20%).
• Add 10% service charge to the final discounted bill amount.
• Display the original bill amount, total discount applied, service charge, and the final
amount to pay.
6. Sum of Even Numbers
Write a program to calculate the sum of the first N even natural numbers:
• Example: If N = 4, sum = 2 + 4 + 6 + 8 = 20.
• Ask the user for N and use a loop to compute the sum.
7. Sum of Odd Numbers
Develop a program to compute the sum of the first N odd natural numbers:
• Example: If N = 5, sum = 1 + 3 + 5 + 7 + 9 = 25.
• Use a loop to calculate the result.
8. Sum of Natural Numbers
Write a program to compute the sum of the first N NATURAL numbers in C using loop [1 + 2 + 3 + ...].
• Ask the user for N.
• Example: If N = 4, output: 1 + 2 + 3 + 4 = 10
9. Sum of Squares
Create a program to calculate the sum of the squares of the first N numbers in C using loop [1² + 2² +
3² + ...].
• Ask the user for N.
• Example: If N =3, output: 1² + 2² + 3² = 14
10. Perfect Number Check
Develop a program to check if a number is a perfect number:
• A perfect number is equal to the sum of its proper divisors (excluding itself).
• Example: 6 is perfect (1 + 2 + 3 = 6).