0
0
Cprogramming~10 mins

Splitting code into multiple files - 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 header file utils.h in main.c.

C
#include [1]

int main() {
    return 0;
}
Drag options to blanks, or click blank then click option'
A<stdio.h>
B"stdio.h"
C"utils.h"
D<utils.h>
Attempts:
3 left
💡 Hint
Common Mistakes
Using angle brackets for user header files.
Forgetting to include the header file.
2fill in blank
medium

Complete the function declaration in utils.h to declare a function named add that takes two integers and returns an integer.

C
int [1](int a, int b);
Drag options to blanks, or click blank then click option'
Aplus
Badd
Caddition
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different function name than 'add'.
Omitting the semicolon at the end.
3fill in blank
hard

Fix the error in utils.c by completing the function definition of add.

C
int [1](int a, int b) {
    return a + b;
}
Drag options to blanks, or click blank then click option'
Aadd
Bsum
Caddition
Dplus
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different function name in definition than declaration.
Mismatched function signatures.
4fill in blank
hard

Fill both blanks to correctly compile main.c and utils.c into an executable named program.

C
gcc [1] [2] -o program
Drag options to blanks, or click blank then click option'
Amain.c
Butils.c
Cprogram.c
Dlib.c
Attempts:
3 left
💡 Hint
Common Mistakes
Compiling only one source file.
Using wrong file names.
5fill in blank
hard

Fill all three blanks to create a header guard in utils.h to prevent multiple inclusions.

C
#ifndef [1]
#define [2]

// function declarations

#endif // [3]
Drag options to blanks, or click blank then click option'
AUTILS_H
BUTILS_H_
CUTILS_H_INCLUDED
DUTILS_H_GUARD
Attempts:
3 left
💡 Hint
Common Mistakes
Using different macro names in the guard.
Forgetting to add header guards.