C Programming Test
Instructions: Answer all the questions. Show proper working wherever required.
Section A: Increment & Decrement Operators (2 Questions)
Q1. [Numerical] If a = 5, find the values of a after each step:
• Step 1 → b = a++
• Step 2 → c = ++a
Find the final values of a, b, and c.
Q2. [Numerical] Consider the code:
int a = 11, b = 22, c;
c = a + b + a++ + b++ + ++a + ++b;
Find the final values of a, b, and c.
Section B: C Output-Based Questions (2 Questions)
Q3. [Output Prediction] What will be the output?
#include
int main() {
int x = 2, y = 5;
printf("%d\n", x * y / x);
printf("%d", x + y - x);
return 0;
}
Q4. [Output Prediction] What will be the output?
#include
int main() {
int a = 3;
a *= 2 + 5;
printf("%d", a);
return 0;
}
Section C: Programs Based on If-Else (3 Questions)
Q5. [Programming] Write a C program to check whether a given number is divisible by 5
and 3 or not.
Q6. [Programming] Write a C program to find the largest of three numbers entered by the
user.
Q7. [Programming] Write a C program to calculate the grade of a student based on the
marks entered:
• Marks ≥ 90 → Grade A
• Marks ≥ 75 → Grade B
• Marks ≥ 50 → Grade C
• Otherwise → Grade F
Section D: Theory Questions (3 Questions)
Q8. [Short Answer] What is the difference between constants and variables in C? Give
one example of each.
Q9. [Short Answer] Explain the rules for naming variables in C and provide three examples
of valid variable names and two examples of invalid variable names.
Q10. [Short Answer] Explain the difference between the following operators in C:
• '=' (Assignment operator)
• '==' (Comparison operator)
Marking Scheme
Section Questions Marks per Q Total Marks
Increment/Decrement Q1 – Q2 2 4
Output Prediction Q3 – Q4 2 4
If-Else Programs Q5 – Q7 3 9
Theory Q8 – Q10 1 3
Total 10 - 20