C Programming Quiz Questions
1. What is the correct syntax to declare a variable in C?
A) int x;
B) x = int;
C) declare x as int;
D) integer x;
Answer: A
2. Which of the following is not a valid C data type?
A) int
B) float
C) boolean
D) char
Answer: C
3. What will be the output of the following code?
int x = 5;
printf("%d", x++);
A) 5
B) 6
C) Undefined
D) Compiler error
Answer: A
4. Which of the following operators has the highest precedence?
A) +
B) &&
C) *
D) =
Answer: C
5. What is the output of the following code snippet?
int a = 10;
if (a > 5)
printf("Yes ");
else
printf("No ");
A) Yes
B) No
C) Yes No
D) No Yes
Answer: A
6. Which loop will always execute at least once, regardless of the condition?
A) for
B) while
C) do-while
D) None of the above
Answer: C
7. What is the function of the break statement in loops?
A) Terminates the program
B) Ends the current loop and transfers control outside the loop
C) Skips the current iteration
D) Pauses the loop temporarily
Answer: B
8. In C, what does the sizeof() operator return?
A) Number of elements in an array
B) Memory size (in bytes) of a variable or data type
C) Length of a string
D) None of the above
Answer: B
9. What is the default return type of the main function in C?
A) int
B) void
C) float
D) char
Answer: A
10. What will be the output of the following code?
int a = 5;
int b = 6;
printf("%d", a + b);
A) 10
B) 11
C) 5
D) 6
Answer: B