SPC CAT-1: Mock 1 (Highest Priority)
Pattern: 5 coding questions (2 Easy + 2 Medium + 1 Hard) covering fundamental C input/output, conditional logic, and math.
← Back to Mocks Overview
Easy 1 — Employee Salary Report
Read:
employee_id
initial
basic_salary
bonus_percentage
Calculate the bonus and final salary.
Input
101 A 25000 10
Output
101 A
Bonus: 2500.00
Final Salary: 27500.00
Another Input
102 B 0 0
Output
102 B
Bonus: 0.00
Final Salary: 0.00
Another Input
103 C 50000 5.5
Output
103 C
Bonus: 2750.00
Final Salary: 52750.00
Another Input
104 D 1000 100
Output
104 D
Bonus: 1000.00
Final Salary: 2000.00
You should be able to handle:
intcharfloatscanfprintf- format specifiers
- arithmetic
- percentage calculation
- formatted output
View Solution
#include <stdio.h>
int main()
{
int employee_id;
char initial;
float basic_salary, bonus_percentage;
float bonus, final_salary;
scanf("%d %c %f %f",
&employee_id,
&initial,
&basic_salary,
&bonus_percentage);
bonus = basic_salary * bonus_percentage / 100.0;
final_salary = basic_salary + bonus;
printf("%d %c\n", employee_id, initial);
printf("Bonus: %.2f\n", bonus);
printf("Final Salary: %.2f\n", final_salary);
return 0;
}
Easy 2 — Days → Years, Weeks, Days
Given total number of days, convert it into:
years weeks days
Assume:
1 year = 365 days
1 week = 7 days
Input
800
Output
2 10 0
Another Input
0
Output
0 0 0
Another Input
364
Output
0 52 0
Another Input
365
Output
1 0 0
Another Input
7
Output
0 1 0
You need:
/
%
View Solution
#include <stdio.h>
int main()
{
int total_days;
int years, weeks, days;
scanf("%d", &total_days);
years = total_days / 365;
total_days %= 365;
weeks = total_days / 7;
days = total_days % 7;
printf("%d %d %d\n", years, weeks, days);
return 0;
}
Medium 1 — Student Eligibility
A student is eligible only if:
marks >= 60
attendance >= 75
assignments >= 5
Use relational + logical operators and the conditional operator.
Input
72 82 6
Output
Eligible
Another Input
72 65 6
Output
Not Eligible
Another Input
59 80 5
Output
Not Eligible
Another Input
60 75 5
Output
Eligible
Another Input
80 80 4
Output
Not Eligible
Use:
&&
>=
?:
View Solution
#include <stdio.h>
int main()
{
int marks, attendance, assignments;
scanf("%d %d %d",
&marks,
&attendance,
&assignments);
printf("%s\n",
(marks >= 60 &&
attendance >= 75 &&
assignments >= 5)
? "Eligible"
: "Not Eligible");
return 0;
}
Medium 2 — Character Classifier
Read one character and print:
Uppercase
Lowercase
Digit
Special Character
Example 1
Input:
A
Output:
Uppercase
Example 2
Input:
7
Output:
Digit
Example 3
Input:
#
Output:
Special Character
Another Input
z
Output
Lowercase
Another Input
Z
Output
Uppercase
Another Input
0
Output
Digit
Another Input
Output
Special Character
Use:
isupper()
islower()
isdigit()
from:
#include <ctype.h>
View Solution
#include <stdio.h>
#include <ctype.h>
int main()
{
char ch;
scanf(" %c", &ch);
printf("%s\n",
isupper(ch) ? "Uppercase" :
islower(ch) ? "Lowercase" :
isdigit(ch) ? "Digit" :
"Special Character");
return 0;
}
Hard 1 — Electricity Bill Using Nested Conditional Operator
Calculate an electricity bill using progressive slabs:
0–100 units → ₹2/unit
101–300 units → ₹3/unit for units above 100
301–600 units → ₹5/unit for units above 300
Above 600 → ₹7/unit for units above 600
After calculating the slab bill:
Add ₹100 service charge.
If the bill after service charge is greater than ₹2000,
add a 10% surcharge.
Use nested ?: for the slab calculation and for the surcharge decision.
Input
250
Output
750.00
Another Input
50
Output
200.00
Another Input
100
Output
300.00
Another Input
200
Output
600.00
Another Input
300
Output
900.00
Another Input
500
Output
1900.00
Another Input
600
Output
2640.00
Another Input
1000
Output
5720.00
Explanation for 250 units:
100 × 2
150 × 3
+ 100 service charge
= 750
This covers:
- progressive slab calculations
- arithmetic
- relational operators
- nested conditional operator
- surcharge logic
- floating-point output
View Solution
#include <stdio.h>
int main()
{
int units;
double bill;
double surcharge;
scanf("%d", &units);
bill =
units <= 100
? units * 2.0
: units <= 300
? 100 * 2.0 +
(units - 100) * 3.0
: units <= 600
? 100 * 2.0 +
200 * 3.0 +
(units - 300) * 5.0
: 100 * 2.0 +
200 * 3.0 +
300 * 5.0 +
(units - 600) * 7.0;
bill += 100.0;
surcharge =
bill > 2000.0
? bill * 0.10
: 0.0;
bill += surcharge;
printf("%.2f\n", bill);
return 0;
}