0
0
Cprogramming~10 mins

Reusability and maintenance - Interactive Code Practice

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

Complete the code to declare a reusable function that adds two integers.

C
int add(int a, int b) {
    return a [1] b;
}
Drag options to blanks, or click blank then click option'
A+
B-
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction or multiplication instead of addition.
Forgetting to return the result.
2fill in blank
medium

Complete the code to call the function add with arguments 5 and 3.

C
int result = [1](5, 3);
Drag options to blanks, or click blank then click option'
Aadd
Bsum
Ccalculate
Dtotal
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different function name that does not exist.
Forgetting to use parentheses for the function call.
3fill in blank
hard

Fix the error in the function prototype to ensure proper reusability.

C
int [1](int a, int b);
Drag options to blanks, or click blank then click option'
AaddNumbers
BAdd
Cadd
Daddition
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different or capitalized function name.
Mismatching the prototype and definition names.
4fill in blank
hard

Fill both blanks to create a reusable function that multiplies two numbers and returns the result.

C
int [1](int x, int y) {
    return x [2] y;
}
Drag options to blanks, or click blank then click option'
Amultiply
B+
C*
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition or subtraction instead of multiplication.
Using a function name that does not describe multiplication.
5fill in blank
hard

Fill all three blanks to create a reusable function that checks if a number is even and returns 1 if true, else 0.

C
int [1](int num) {
    if (num [2] 2 [3] 0) {
        return 1;
    } else {
        return 0;
    }
}
Drag options to blanks, or click blank then click option'
AisEven
B%
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect operators like != instead of ==.
Choosing a function name that does not describe the check.