0
0
Cprogramming~10 mins

Include guards - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start an include guard with the correct directive.

C
#[1] MY_HEADER_H
Drag options to blanks, or click blank then click option'
Ainclude
Bdefine
Cifndef
Dendif
Attempts:
3 left
💡 Hint
Common Mistakes
Using #define instead of #ifndef to start the guard.
Using #include instead of a preprocessor directive.
2fill in blank
medium

Complete the code to define the macro for the include guard.

C
#ifndef MY_HEADER_H
#[1] MY_HEADER_H
Drag options to blanks, or click blank then click option'
Aifndef
Bdefine
Cinclude
Dendif
Attempts:
3 left
💡 Hint
Common Mistakes
Using #ifndef again instead of #define.
Using #endif instead of #define.
3fill in blank
hard

Fix the error in the code to properly close the include guard.

C
#ifndef MY_HEADER_H
#define MY_HEADER_H
// header content
#[1]
Drag options to blanks, or click blank then click option'
Aendif
Binclude
Cifndef
Ddefine
Attempts:
3 left
💡 Hint
Common Mistakes
Using #define or #ifndef instead of #endif at the end.
Omitting the closing directive.
4fill in blank
hard

Fill both blanks to complete a proper include guard.

C
#[1] MY_HEADER_H
#[2] MY_HEADER_H
// header content
#endif
Drag options to blanks, or click blank then click option'
Aifndef
Bdefine
Cinclude
Dendif
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of #ifndef and #define.
Using #include or #endif in these positions.
5fill in blank
hard

Fill all three blanks to write a complete include guard.

C
#[1] MY_HEADER_H
#[2] MY_HEADER_H
// content
#[3]
Drag options to blanks, or click blank then click option'
Aifndef
Bdefine
Cendif
Dinclude
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to close the guard with #endif.
Using #include instead of #define or #endif.