SPC CAT-1: 11 Extra Questions (Additional Syllabus Coverage)
Coverage: 11 additional questions filling syllabus gaps: compound/unary operators, escape sequences, constants, prototypes, bitwise manipulation, and string copying.
← Back to Mocks Overview
These 4 problems cover the remaining coding concepts that were not directly exercised by the 15 mock questions.
Add-On 1 — Compound Assignment + Unary Operators
Read two integers:
x b
Perform these operations in order:
x += b;
x -= b;
x *= b;
x /= b;
x %= b;
x = -x;
Assume b != 0.
Print the final value.
Input
10 3
Output
-1
Another Input
0 5
Output
0
Another Input
-5 2
Output
1
Another Input
100 7
Output
-2
This covers:
+=
-=
*=
/=
%=
unary -
View Solution
#include <stdio.h>
int main()
{
int x, b;
scanf("%d %d", &x, &b);
x += b;
x -= b;
x *= b;
x /= b;
x %= b;
x = -x;
printf("%d\n", x);
return 0;
}
Add-On 2 — Escape Sequences + Formatted Output
Read:
name_initial
marks
Print exactly:
Student: A
Marks: 78
"Result Recorded"
where the gaps after : must be produced using tabs.
Input
A 78
Output
Student: A
Marks: 78
"Result Recorded"
Another Input
B 10
Output
Student: B
Marks: 10
"Result Recorded"
Another Input
Z 100
Output
Student: Z
Marks: 100
"Result Recorded"
Another Input
X 0
Output
Student: X
Marks: 0
"Result Recorded"
Use:
\t
\n
\"
View Solution
#include <stdio.h>
int main()
{
char initial;
int marks;
scanf(" %c %d", &initial, &marks);
printf("Student:\t%c\n", initial);
printf("Marks:\t%d\n", marks);
printf("\"Result Recorded\"\n");
return 0;
}
Add-On 3 — Constants + Data Types + Basic C Structure
Read the radius of a circle.
Another Input
0
Output
Area: 0.00
Circumference: 0.00
Another Input
3.14159
Output
Area: 31.01
Circumference: 19.74
Another Input
-100
Output
Area: 31415.90
Circumference: -628.32
Use:
const double PI = 3.14159;
Calculate:
Area
Circumference
Input
5
Output
Area: 78.54
Circumference: 31.42
This specifically touches:
constdouble- identifiers
- variables
- constants
- declarations
- formatted output
- basic C structure
View Solution
#include <stdio.h>
int main()
{
const double PI = 3.14159;
double radius;
double area;
double circumference;
scanf("%lf", &radius);
area = PI * radius * radius;
circumference = 2 * PI * radius;
printf("Area: %.2f\n", area);
printf("Circumference: %.2f\n", circumference);
return 0;
}
Add-On 4 — Function Prototype + Modular Programming
Write these functions:
float calculatePercentage(int obtained, int total);
char calculateGrade(float percentage);
Grades:
>= 90 → A
>= 75 → B
>= 60 → C
>= 40 → D
else → F
Declare the function prototypes before main(), define the functions after main(), and use them to print percentage and grade.
Input
47 60
Output
78.33
B
Another Input
0 100
Output
0.00
F
Another Input
-5 51
Output
-9.80
F
Another Input
10 51
Output
19.61
F
This covers:
- function prototypes
- modular programming
- function parameters
- return values
- type conversion
- conditional operator
- program organization
View Solution
#include <stdio.h>
float calculatePercentage(int obtained, int total);
char calculateGrade(float percentage);
int main()
{
int obtained, total;
float percentage;
char grade;
scanf("%d %d", &obtained, &total);
percentage =
calculatePercentage(obtained, total);
grade = calculateGrade(percentage);
printf("%.2f\n", percentage);
printf("%c\n", grade);
return 0;
}
float calculatePercentage(int obtained, int total)
{
return (float)obtained / total * 100.0;
}
char calculateGrade(float percentage)
{
return percentage >= 90 ? 'A' :
percentage >= 75 ? 'B' :
percentage >= 60 ? 'C' :
percentage >= 40 ? 'D' :
'F';
}
Add-On 5 — Operator Precedence + Associativity
Read three integers a, b, and c.
Calculate:
r1 = a + b * c;
r2 = (a + b) * c;
r3 = a / b * c;
All calculations use normal C integer arithmetic.
Input
10 5 2
Output
20 30 4
Another Input
0 5 2
Output
10 10 0
Another Input
1 1 1
Output
2 2 1
Another Input
-5 10 -2
Output
-25 -10 0
This covers:
- operator precedence
- parentheses
- left-to-right associativity of
*and/ - integer division
- expression evaluation
View Solution
#include <stdio.h>
int main()
{
int a, b, c;
int r1, r2, r3;
scanf("%d %d %d", &a, &b, &c);
r1 = a + b * c;
r2 = (a + b) * c;
r3 = a / b * c;
printf("%d %d %d\n", r1, r2, r3);
return 0;
}
Add-On 6 — Wallet Transaction Validator
Read:
balance
purchase
A transaction is valid only if:
purchase > 0
purchase <= balance
purchase is a multiple of 50
Cashback:
purchase >= 5000 → 10%
purchase >= 2000 → 5%
otherwise → 2%
If the transaction is valid:
finalBalance = balance - purchase + cashback
Otherwise print:
Invalid Transaction
Input
10000 5000
Output
5500.00
Another Input
10000 5125
Output
Invalid Transaction
Another Input
0 0
Output
Invalid Transaction
Another Input
1000 -500
Output
Invalid Transaction
Another Input
500 1000
Output
Invalid Transaction
Another Input
5000 5000
Output
500.00
This covers:
- relational operators
&&- type casting
- modulus
- nested conditional operator
- validation logic
- floating-point calculation
View Solution
#include <stdio.h>
int main()
{
double balance, purchase;
int valid;
double cashback_rate;
double final_balance;
scanf("%lf %lf", &balance, &purchase);
valid =
purchase > 0 &&
purchase <= balance &&
((int)purchase % 50 == 0);
cashback_rate =
purchase >= 5000 ? 0.10 :
purchase >= 2000 ? 0.05 :
0.02;
final_balance =
balance - purchase +
purchase * cashback_rate;
valid
? printf("%.2f\n", final_balance)
: printf("Invalid Transaction\n");
return 0;
}
Add-On 7 — Math Rounding Report
Read one floating-point value and print:
Ceil
Floor
Round
Use functions from:
#include <math.h>
Input
7.3
Output
Ceil: 8
Floor: 7
Round: 7
Another Input
0.0
Output
Ceil: 0
Floor: 0
Round: 0
Another Input
-5.5
Output
Ceil: -5
Floor: -6
Round: -6
Another Input
5.1
Output
Ceil: 6
Floor: 5
Round: 5
Another Input
-5.9
Output
Ceil: -5
Floor: -6
Round: -6
Use:
ceil()
floor()
round()
View Solution
#include <stdio.h>
#include <math.h>
int main()
{
double x;
scanf("%lf", &x);
printf("Ceil: %.0f\n", ceil(x));
printf("Floor: %.0f\n", floor(x));
printf("Round: %.0f\n", round(x));
return 0;
}
Add-On 8 — Character I/O + Literal Percent Sign
Read:
grade
percentage
Read the grade using getchar().
Print the grade using putchar() and print the percentage with a literal % sign.
Input
A 78.5
Output
Grade: A
Percentage: 78.50%
Another Input
a
Output
Grade: a
Percentage: 0.00%
Another Input
Z
Output
Grade: Z
Percentage: 0.00%
Another Input
0
Output
Grade: 0
Percentage: 0.00%
Another Input
Output
Grade:
Percentage: 0.00%
This covers:
getchar()putchar()- character input/output
printf()%%for printing a percent sign- formatted floating-point output
View Solution
#include <stdio.h>
int main()
{
char grade;
float percentage;
grade = getchar();
scanf("%f", &percentage);
printf("Grade: ");
putchar(grade);
printf("\n");
printf("Percentage: %.2f%%\n", percentage);
return 0;
}
Add-On 9 — Relational + Logical + Unary Operator Report
Read two integers a and b.
Print the results of all relational operators, the three logical operators, and unary + / - on a.
Input
5 0
Output
0 1 0 1 0 1
0 1 0 1
5 -5
Output order:
a<b a>b a<=b a>=b a==b a!=b
a&&b a||b !a !b
+a -a
Another Input
0 0
Output
0 0 1 1 1 0
0 0 1 1
0 0
Another Input
-5 5
Output
1 0 1 0 0 1
1 1 0 0
-5 5
Another Input
10 10
Output
0 0 1 1 1 0
1 1 0 0
10 -10
Another Input
100 -100
Output
0 1 0 1 0 1
1 1 0 0
100 -100
View Solution
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d %d %d %d %d %d\n",
a < b,
a > b,
a <= b,
a >= b,
a == b,
a != b);
printf("%d %d %d %d\n",
a && b,
a || b,
!a,
!b);
printf("%d %d\n", +a, -a);
return 0;
}
Add-On 10 — Bitwise Operator Report — Teacher-Material Exception
This is not in the clean final syllabus image, but bitwise programs and XOR swapping were directly present in the teacher material, so it is retained as an exam-safety question.
Read two integers a and b.
Print:
a & b
a | b
a ^ b
~a
a << 1
a >> 1
Input
5 3
Output
1 7 6 -6 10 2
Another Input
0 0
Output
0 0 0 -1 0 0
Another Input
-1 -1
Output
-1 -1 0 0 -2 -1
Another Input
10 5
Output
0 15 15 -11 20 5
View Solution
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d %d %d %d %d %d\n",
a & b,
a | b,
a ^ b,
~a,
a << 1,
a >> 1);
return 0;
}
Add-On 11 — Copy a String Using strcpy()
Read a single word into source.
Copy it into another string destination using:
strcpy()
Then print the copied string.
Input
Chitkara
Output
Chitkara
This covers another directly practised string.h operation in addition to strlen().
Another Input
A
Output
A
Another Input
Hello_World
Output
Hello_World
Another Input
12345
Output
12345
View Solution
#include <stdio.h>
#include <string.h>
int main()
{
char source[100];
char destination[100];
scanf("%s", source);
strcpy(destination, source);
printf("%s\n", destination);
return 0;
}