0
0
Cprogramming~10 mins

Why modular programming is needed in C - Test Your Understanding

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

Complete the code to declare a function prototype for modular programming.

C
void [1]();
Drag options to blanks, or click blank then click option'
Acalculate
Bmain
Cprintf
Dreturn
Attempts:
3 left
💡 Hint
Common Mistakes
Using main as a prototype name here, which is reserved for the program entry point.
Using keywords like return instead of a function name.
2fill in blank
medium

Complete the code to call a function named processData.

C
[1]();
Drag options to blanks, or click blank then click option'
Areturn
Bint
CprocessData
Dvoid
Attempts:
3 left
💡 Hint
Common Mistakes
Using return as a function call.
Using data types like int or void instead of the function name.
3fill in blank
hard

Fix the error in the function definition by completing the missing return type.

C
[1] add(int a, int b) {
    return a + b;
}
Drag options to blanks, or click blank then click option'
Afloat
Bint
Cvoid
Dchar
Attempts:
3 left
💡 Hint
Common Mistakes
Using void which means no value is returned.
Using float or char which do not match the returned integer.
4fill in blank
hard

Fill both blanks to create a modular program that calls a function and prints the result.

C
#include <stdio.h>

int [1](int x, int y) {
    return x + y;
}

int main() {
    int result = [2](5, 3);
    printf("Result: %d\n", result);
    return 0;
}
Drag options to blanks, or click blank then click option'
Aadd
Bmain
Cprintf
Dreturn
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for the function definition and call.
Using reserved function names incorrectly.
5fill in blank
hard

Fill all five blanks to complete a modular program with function declaration, definition, and call.

C
#include <stdio.h>

[1] [2](int a, int b);

int main() {
    int sum = [3](10, 20);
    printf("Sum is %d\n", sum);
    return 0;
}

[4] [5](int a, int b) {
    return a + b;
}
Drag options to blanks, or click blank then click option'
Aint
Bvoid
Cadd
Dmain
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching return types between declaration and definition.
Using different names for declaration, definition, and call.