0
0
Cprogramming~10 mins

Compilation process in C - Interactive Code Practice

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

Complete the code to include the standard input-output header.

C
#include [1]

int main() {
    printf("Hello, world!\n");
    return 0;
}
Drag options to blanks, or click blank then click option'
A<math.h>
B<stdlib.h>
C<string.h>
D<stdio.h>
Attempts:
3 left
💡 Hint
Common Mistakes
Including instead of causes undefined reference to printf.
Forgetting the angle brackets around the header name.
2fill in blank
medium

Complete the command to compile a C file named program.c using gcc.

C
gcc [1] -o program
Drag options to blanks, or click blank then click option'
Aprogram
B-c
Cprogram.c
D-o
Attempts:
3 left
💡 Hint
Common Mistakes
Using the output file name instead of the source file.
Confusing the -o option with the source file.
3fill in blank
hard

Fix the error in the compilation command to generate only the object file.

C
gcc -o program.o [1] program.c
Drag options to blanks, or click blank then click option'
A-c
Bprogram.o
Cprogram.c
D-o
Attempts:
3 left
💡 Hint
Common Mistakes
Placing -o before -c incorrectly.
Omitting the -c option when only compiling.
4fill in blank
hard

Fill both blanks to complete the compilation stages in order.

C
gcc -E [1] -o [2]
Drag options to blanks, or click blank then click option'
Aprogram.c
Bprogram.i
Cprogram.o
Dprogram.s
Attempts:
3 left
💡 Hint
Common Mistakes
Using the object file .o or assembly file .s as output for preprocessing.
Confusing input and output file names.
5fill in blank
hard

Fill all three blanks to complete the compilation pipeline: preprocessing, compiling, and assembling.

C
gcc -E [1] -o [2]
gcc -S [2] -o [3]
Drag options to blanks, or click blank then click option'
Aprogram.c
Bprogram.i
Cprogram.s
Dprogram.o
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up file extensions for each stage.
Using object file .o instead of assembly .s for the compile output.