Q. What does the sizeof operator return?

  • (A) Pointer size
  • (B) Data type
  • (C) Memory size in bytes
  • (D) Address value
πŸ’¬ Discuss
βœ… Correct Answer: (C) Memory size in bytes
Explanation: sizeof returns size of a variable or type in bytes.

Q. What is the output?

Code:
int a = 5;
int b = ++a + a++;
printf("%d", b);
  • (A) 11
  • (B) 12
  • (C) 13
  • (D) 10
πŸ’¬ Discuss
βœ… Correct Answer: (B) 12
Explanation: ++a = 6, a++ uses 6 and becomes 7 => 6+6 = 12

Q. Which is used to declare a constant pointer to integer?

  • (A) int const *p
  • (B) int * const p
  • (C) const int *p
  • (D) int *p const
πŸ’¬ Discuss
βœ… Correct Answer: (B) int * const p
Explanation: int * const p declares a pointer that cannot point elsewhere.

Q. What does calloc() do differently than malloc()?

  • (A) Allocates memory of zero bytes
  • (B) Initializes allocated memory to zero
  • (C) Faster than malloc
  • (D) Returns a double pointer
πŸ’¬ Discuss
βœ… Correct Answer: (B) Initializes allocated memory to zero
Explanation: calloc() sets all allocated bytes to zero, unlike malloc().

Q. What does 'r' mode in fopen mean?

  • (A) Read only
  • (B) Write only
  • (C) Append
  • (D) Read and Write
πŸ’¬ Discuss
βœ… Correct Answer: (A) Read only
Explanation: 'r' mode opens a file for reading only.

Q. What will the following code print?

Code:
int a = 5;
printf("%d %d", a++, ++a);
  • (A) 5 6
  • (B) 6 6
  • (C) Undefined behavior
  • (D) 6 7
πŸ’¬ Discuss
βœ… Correct Answer: (C) Undefined behavior
Explanation: Modifying a variable more than once in the same statement causes undefined behavior.

Q. Which of the following is not a valid file operation mode in fopen()?

  • (A) r+
  • (B) rb
  • (C) rw
  • (D) w+
πŸ’¬ Discuss
βœ… Correct Answer: (C) rw
Explanation: There is no 'rw' mode in fopen(); use 'r+' or 'w+' instead.

Q. What does the 'ftell()' function return?

  • (A) File size
  • (B) File pointer position
  • (C) Error code
  • (D) Line number
πŸ’¬ Discuss
βœ… Correct Answer: (B) File pointer position
Explanation: ftell() returns the current value of the file position indicator.

Q. What is the output of the following?

Code:
#define SQUARE(x) x*x
printf("%d", SQUARE(3+1));
  • (A) 16
  • (B) 7
  • (C) 13
  • (D) Compiler Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) 7
Explanation: Macro expands to 3+1*3+1 = 3+3+1 = 7 due to lack of parentheses.

Q. Which of the following is true about macros?

  • (A) They are type-checked
  • (B) They consume memory
  • (C) They are faster than functions
  • (D) They are executed at runtime
πŸ’¬ Discuss
βœ… Correct Answer: (C) They are faster than functions
Explanation: Macros are expanded at compile time, hence faster.