Recall & Review
beginner
Why do we split C code into multiple files?
Splitting code into multiple files helps organize the program better, makes it easier to manage, and allows multiple people to work on different parts at the same time.
Click to reveal answer
beginner
What is a header file (.h) used for in C?
A header file contains declarations like function prototypes and variable declarations that other files can use to know how to interact with the code without seeing the full details.
Click to reveal answer
beginner
How do you include one file in another in C?
You use the #include directive with the file name in quotes for your own files, like #include "myfile.h".
Click to reveal answer
beginner
What command compiles multiple C files together?
You can compile multiple files by listing them all in the compiler command, for example: gcc main.c utils.c -o program
Click to reveal answer
beginner
What is the role of a .c file compared to a .h file?
A .c file contains the actual code (function definitions), while a .h file contains declarations (function prototypes and constants) to share with other files.
Click to reveal answer
Which file type usually contains function declarations in C?
✗ Incorrect
Header files (.h) contain declarations like function prototypes.
How do you tell the compiler to compile multiple C files together?
✗ Incorrect
You list all source files in the compiler command, like gcc main.c utils.c -o program.
What does #include "file.h" do in a C program?
✗ Incorrect
#include literally inserts the content of the header file into the current file before compiling.
Why should you use header files in multi-file C programs?
✗ Incorrect
Header files share declarations so multiple files know about functions and variables.
What happens if you forget to include a header file with function declarations?
✗ Incorrect
Without declarations, the compiler doesn't know about the functions and will report errors.
Explain how to split a simple C program into two files: one for main and one for helper functions.
Think about separating code and sharing declarations.
You got /5 concepts.
Describe the difference between a .c file and a .h file and why both are important.
Focus on code vs declarations and sharing.
You got /5 concepts.