0
0
Cprogramming~10 mins

Function parameters - 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 function that takes one integer parameter.

C
void printNumber([1] num) {
    printf("%d\n", num);
}
Drag options to blanks, or click blank then click option'
Aint
Bchar
Cfloat
Ddouble
Attempts:
3 left
💡 Hint
Common Mistakes
Using a floating-point type like float instead of int.
Using char which is for single characters.
2fill in blank
medium

Complete the function call to pass the variable correctly.

C
int value = 10;
printNumber([1]);
Drag options to blanks, or click blank then click option'
A&value
Bvalue&
C*value
Dvalue
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the address of the variable when the function expects a value.
Using pointer dereference incorrectly.
3fill in blank
hard

Fix the error in the function definition to accept two integer parameters.

C
void addNumbers(int a, [1] b) {
    printf("%d\n", a + b);
}
Drag options to blanks, or click blank then click option'
Afloat
Bint
Cchar
Ddouble
Attempts:
3 left
💡 Hint
Common Mistakes
Using different types for parameters that should be the same.
Using floating-point types when integers are expected.
4fill in blank
hard

Fill both blanks to declare a function that returns the sum of two integers.

C
[1] add([2] a, int b) {
    return a + b;
}
Drag options to blanks, or click blank then click option'
Aint
Bfloat
Cvoid
Ddouble
Attempts:
3 left
💡 Hint
Common Mistakes
Using void as return type when a value is returned.
Using different types for parameters.
5fill in blank
hard

Fill all three blanks to declare and call a function that multiplies two floats and returns the result.

C
[1] multiply([2] x, [3] y) {
    return x * y;
}

float result = multiply(2.5f, 4.0f);
Drag options to blanks, or click blank then click option'
Afloat
Bint
Cdouble
Dvoid
Attempts:
3 left
💡 Hint
Common Mistakes
Using int or double instead of float.
Using void as return type when a value is returned.