Q. Which of the following is correct about array indexing?

  • (A) a[5] = 0 is valid for array of size 5
  • (B) a[0] is always the last element
  • (C) a[-1] is valid
  • (D) a[0] is the first element
πŸ’¬ Discuss
βœ… Correct Answer: (D) a[0] is the first element
Explanation: Arrays in C are 0-indexed, so the first element is a[0].

Q. What is the result of sizeof(char)?

  • (A) 2
  • (B) 1
  • (C) 4
  • (D) Depends on OS
πŸ’¬ Discuss
βœ… Correct Answer: (B) 1
Explanation: The size of a char is always 1 byte in C.

Q. What is the output of the following code?

Code:
int a = 10;
if (a = 0)
    printf("Zero");
else
    printf("Non-zero");
  • (A) Zero
  • (B) Non-zero
  • (C) Compile error
  • (D) Runtime error
πŸ’¬ Discuss
βœ… Correct Answer: (B) Non-zero
Explanation: The assignment 'a = 0' evaluates to false, so the else block runs and prints 'Non-zero'.

Q. Which function is used to dynamically allocate memory in C?

  • (A) calloc()
  • (B) malloc()
  • (C) realloc()
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above
Explanation: All three are used for dynamic memory allocation.

Q. What is the output of the following code?

Code:
int x = 10;
printf("%d", x++);
  • (A) 10
  • (B) 11
  • (C) 9
  • (D) Undefined
πŸ’¬ Discuss
βœ… Correct Answer: (A) 10
Explanation: Post-increment returns value before incrementing.

Q. What is the output of the following code?

Code:
int arr[] = {1,2,3};
printf("%d", *(arr+1));
  • (A) 1
  • (B) 2
  • (C) 3
  • (D) Undefined
πŸ’¬ Discuss
βœ… Correct Answer: (B) 2
Explanation: arr+1 points to the second element of the array.

Q. Which header file is required for using printf()?

  • (A) conio.h
  • (B) math.h
  • (C) stdio.h
  • (D) stdlib.h
πŸ’¬ Discuss
βœ… Correct Answer: (C) stdio.h
Explanation: stdio.h includes declarations for input/output functions.

Q. Which operator is used for conditional branching?

  • (A) if
  • (B) switch
  • (C) ?:
  • (D) &&
πŸ’¬ Discuss
βœ… Correct Answer: (C) ?:
Explanation: The ternary operator (?:) is used for conditional evaluation.

Q. What is the output of this code?

Code:
int a = 1;
if (a)
    printf("True");
else
    printf("False");
  • (A) True
  • (B) False
  • (C) 1
  • (D) Compile Error
πŸ’¬ Discuss
βœ… Correct Answer: (A) True
Explanation: Any non-zero integer in condition is treated as true.

Q. Which of these is used to terminate a C statement?

  • (A) ,
  • (B) .
  • (C) ;
  • (D) :
πŸ’¬ Discuss
βœ… Correct Answer: (C) ;
Explanation: C statements are terminated using semicolons.