0
0
Cprogramming~5 mins

Predefined macros - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a predefined macro in C?
A predefined macro is a special identifier that the C compiler automatically defines before compilation. It provides useful information like the current file name, line number, or compilation date.
Click to reveal answer
beginner
What does the predefined macro __FILE__ represent?
The __FILE__ macro expands to the name of the current source file as a string literal.
Click to reveal answer
beginner
What value does the predefined macro __LINE__ hold?
The __LINE__ macro expands to the current line number in the source file as an integer constant.
Click to reveal answer
intermediate
What information does the predefined macro __DATE__ provide?
The __DATE__ macro expands to a string literal representing the date when the source file was compiled, in the format "Mmm dd yyyy".
Click to reveal answer
intermediate
How can predefined macros help in debugging C programs?
Predefined macros like __FILE__ and __LINE__ can be used to print the current file name and line number, helping programmers quickly find where an error or message originated.
Click to reveal answer
Which predefined macro gives the current line number in a C source file?
A__TIME__
B__FILE__
C__DATE__
D__LINE__
What does the predefined macro __FILE__ return?
AThe current line number
BThe name of the current source file
CThe compilation date
DThe compilation time
Which predefined macro provides the date when the program was compiled?
A__DATE__
B__TIME__
C__FILE__
D__LINE__
How can predefined macros be useful in debugging?
AThey can print the current file and line number
BThey can optimize code speed
CThey can change program logic
DThey can store variable values
Which of these is NOT a standard predefined macro in C?
A__TIME__
B__DATE__
C__COMPILER__
D__FILE__
Explain what predefined macros are in C and list at least three common examples with their purpose.
Think about what information the compiler automatically provides during compilation.
You got /4 concepts.
    Describe how you can use predefined macros to help find bugs in your C program.
    Consider how knowing the exact file and line number can speed up fixing problems.
    You got /3 concepts.