🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Files and Preprocessor: all 10 questions

Quiz: Files and Preprocessor · Question 4 of 10

What is the purpose of a header guard (ifndef … define … endif)?

What is the purpose of a header guard (#ifndef … #define … #endif)?

  1. A.To make code faster
  2. B.To prevent the same header from being included twice
  3. C.To hide functions from other files
  4. D.To declare main
Answer & explanation

Correct answer: To prevent the same header from being included twice

Double inclusion would cause redefinition errors.

Can you get the rest right without peeking?

Take the timed Quiz: Files and Preprocessor quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →