Q. Which of the following can be used as a structure pointer?

  • (A) (*s).x
  • (B) s->x
  • (C) &s.x
  • (D) s.x
πŸ’¬ Discuss
βœ… Correct Answer: (B) s->x
Explanation: s->x is used to access members of a structure pointer.

Q. What is the output?

Code:
int a = 5;
int *p = &a;
*p = 10;
printf("%d", a);
  • (A) 5
  • (B) 10
  • (C) 0
  • (D) Garbage
πŸ’¬ Discuss
βœ… Correct Answer: (B) 10
Explanation: Pointer dereferencing allows modifying the original variable.

Q. What does 'fgetc()' return at EOF?

  • (A) '\0'
  • (B) NULL
  • (C) -1
  • (D) 0
πŸ’¬ Discuss
βœ… Correct Answer: (C) -1
Explanation: fgetc() returns EOF constant, usually -1, when the end of the file is reached.

Q. Which of the following will compile successfully?

Code:
const int a;
a = 5;
  • (A) Yes
  • (B) No
  • (C) Only in C++
  • (D) Only for global vars
πŸ’¬ Discuss
βœ… Correct Answer: (B) No
Explanation: const means the variable cannot be modified once declared.

Q. Which function moves the file pointer to a specified location?

  • (A) fseek()
  • (B) ftell()
  • (C) rewind()
  • (D) fmove()
πŸ’¬ Discuss
βœ… Correct Answer: (A) fseek()
Explanation: fseek() repositions the file pointer to a given location.

Q. What does fclose() return on success?

  • (A) 1
  • (B) 0
  • (C) -1
  • (D) NULL
πŸ’¬ Discuss
βœ… Correct Answer: (B) 0
Explanation: fclose() returns 0 on successful file close.

Q. What happens if you dereference a NULL pointer?

  • (A) Returns 0
  • (B) Segmentation fault
  • (C) Prints NULL
  • (D) Undefined result
πŸ’¬ Discuss
βœ… Correct Answer: (B) Segmentation fault
Explanation: Dereferencing NULL is illegal and causes a segmentation fault.

Q. Which keyword is used to define macros?

  • (A) macro
  • (B) #define
  • (C) define
  • (D) #macro
πŸ’¬ Discuss
βœ… Correct Answer: (B) #define
Explanation: #define is used to create macro definitions in C.

Q. What is a dangling pointer?

  • (A) Pointer to a variable
  • (B) Pointer to freed memory
  • (C) Pointer to null
  • (D) Pointer not initialized
πŸ’¬ Discuss
βœ… Correct Answer: (B) Pointer to freed memory
Explanation: Dangling pointers refer to memory that has been deallocated.

Q. Which of the following is a correct way to define a struct?

  • (A) struct A { int x; }
  • (B) structure A { int x; }
  • (C) class A { int x; }
  • (D) define A { int x; }
πŸ’¬ Discuss
βœ… Correct Answer: (A) struct A { int x; }
Explanation: 'struct' is used to define structures in C.