Apply for Zend Framework Certification Training

c

< Decision Making Statements in C Loops in C >




10 Scenario-Based Questions on Decision-Making Statements in C
With 6 Test Cases Each
1. Student Scholarship Eligibility
A college awards scholarships based on marks and annual family income:
Marks ≥ 90 and income ≤ ?3,00,000 → Full Scholarship
Marks ≥ 75 and income ≤ ?5,00,000 → Half Scholarship
Otherwise → No Scholarship
Write a C program to determine the scholarship category.
Test Cases
Test Case Input: Marks Income Expected Output
1 95 250000 Full Scholarship
2 90 300000 Full Scholarship
3 89 300000 Half Scholarship
4 80 450000 Half Scholarship
5 75 500000 Half Scholarship
6 70 200000 No Scholarship
 
2. Electricity Bill Calculator
An electricity board calculates the bill using these rules:
First 100 units → ?2/unit
Next 100 units → ?3/unit
Above 200 units → ?5/unit
Above 300 units → additional ?100 surcharge
Write a C program to calculate the total electricity bill.
Test Cases
Test Case Input: Units Expected Output
1                       50              Bill = ?100
2                      100             Bill = ?200
3 150 Bill = ?350
4 200 Bill = ?500
5 250 Bill = ?750
6 350 Bill = ?1350
 
3. ATM Withdrawal Validation
An ATM allows a customer to withdraw money only if:
PIN is 1234
Amount is a multiple of ?500
Amount does not exceed ?20,000
Account balance is sufficient
Write a C program to validate the withdrawal and display the appropriate message.
Test Cases
Test Case Input: PIN Balance Amount Expected Output
1 1234 25000 5000 Withdrawal Successful
2 1234 25000 20000 Withdrawal Successful
3 1111 25000 5000 Invalid PIN
4 1234 25000 5500 Invalid Amount
5 1234 50000 25000 Daily Limit Exceeded
6 1234 3000 5000 Insufficient Balance
 
4. Driving License Eligibility
A person applies for a driving license according to these rules:
Below 18 → Not Eligible
Age 18–20 → Learner permit is required
Age 18–20 with a valid permit → Eligible with Learner Permit
Age 21 or above → Directly Eligible
Write a C program to determine the applicant's eligibility.
Test Cases
Test Case Input: Age Permit Expected Output
1 16 0 Not Eligible
2 17 1 Not Eligible
3 18 1 Eligible with Learner Permit
4 18 0 Learner Permit Required
5 20 1 Eligible with Learner Permit
6 25 0 Directly Eligible
 
5. Employee Bonus System
A company gives bonuses according to experience and performance rating:
Experience ≥ 10 years and rating ≥ 8 → 20% bonus
Experience ≥ 5 years and rating ≥ 7 → 15% bonus
Experience ≥ 2 years and rating ≥ 5 → 10% bonus
Otherwise → No Bonus
Write a C program to calculate the employee's bonus amount.
Test Cases
Test Case Input: Salary Experience Rating Expected Output
1 50000 12 9 Bonus = ?10000
2 60000 10 8 Bonus = ?12000
3 40000 7 7 Bonus = ?6000
4 30000 5 6 Bonus = ?3000
5 25000 2 5 Bonus = ?2500
6 50000 1 9 Bonus = ?0
 
6. Online Shopping Discount
An online store provides discounts based on purchase amount:
?10,000 or more → 20%
?5,000–?9,999 → 10%
?2,000–?4,999 → 5%
Below ?2,000 → No discount
Premium members receive an additional 5% discount.
Write a C program to calculate the final payable amount.
Test Cases
Test Case Input: Amount Premium Expected Output
1                      12000 0 Final Amount = ?9600
2                      10000 1 Final Amount = ?7500
3                      7000 0 Final Amount = ?6300
4                      4000 1 Final Amount = ?3600
5                      2000 0 Final Amount = ?1900
6                      1500 1 Final Amount = ?1425
Premium: 1 = Yes, 0 = No
 
7. Temperature Alert System
A weather station classifies temperature as:
Below 0°C → Freezing
0–15°C → Cold
16–30°C → Normal
31–40°C → Hot
Above 40°C → Extreme Heat
Above 45°C → Also display Emergency Warning
Write a C program to classify the temperature.
Test Cases
Test Case Input: Temperature Expected Output
1 -5 Freezing
2 0 Cold
3 15 Cold
4 25 Normal
5 40 Hot
6 46 Extreme Heat - Emergency Warning
 
8. Bank Loan Approval
A bank evaluates a loan applicant using the following conditions:
Age must be between 21 and 60
Salary must be at least ?30,000
Credit score ≥ 750 → Low Interest Loan
Credit score 650–749 → Standard Loan
Credit score < 650 → Loan Rejected
Write a C program to determine the loan decision.
Test Cases
Test Case Input: Age Salary Credit Score Expected Output
1 30 50000 800 Low Interest Loan
2 21 30000 750 Low Interest Loan
3 40 45000 700 Standard Loan
4 60 60000 650 Standard Loan
5 20 50000 800 Loan Rejected
6 40 25000 800 Loan Rejected
 
9. Exam Result and Grade
A university evaluates marks in three subjects.
If any subject is below 35 → Fail
Otherwise calculate the average:
Average ≥ 90 → Grade A
Average ≥ 75 → Grade B
Average ≥ 60 → Grade C
Average ≥ 50 → Grade D
Below 50 → Grade E
Write a C program to determine the student's result and grade.
Test Cases
Test Case Input: M1 M2 M3 Expected Output
1 95 92 93 Grade A
2 80 75 85 Grade B
3 70 65 68 Grade C
4 55 52 58 Grade D
5 40 45 48 Grade E
6 90 95 30 Fail
 
10. Mobile Data Plan Selection
A telecom company recommends a plan based on monthly data usage:
≤ 2 GB → Basic Plan
2 GB and ≤ 10 GB → Standard Plan
10 GB and ≤ 30 GB → Premium Plan
30 GB → Unlimited Plan
Business customers automatically receive a Business Plan, regardless of their data usage.
Write a C program to determine the appropriate plan.
Test Cases
Test Case Input: Data GB Customer Type Expected Output
1 1.5 0 Basic Plan
2 2 0 Basic Plan
3 8 0 Standard Plan
4 25 0 Premium Plan
5 35 0 Unlimited Plan
6 1 1 Business Plan
 
Customer Type: 0 = Regular, 1 = Business

< Decision Making Statements in C Loops in C >



Ask a question



  • Question:
    {{questionlistdata.blog_question_description}}
    • Answer:
      {{answer.blog_answer_description  }}
    Replay to Question


Back to Top