Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a floating-point type like float instead of int.
Using char which is for single characters.
✗ Incorrect
The function parameter should be of type int to accept an integer.
2fill in blank
mediumComplete the function call to pass the variable correctly.
C
int value = 10; printNumber([1]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the address of the variable when the function expects a value.
Using pointer dereference incorrectly.
✗ Incorrect
The function expects an integer value, so pass the variable value directly.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different types for parameters that should be the same.
Using floating-point types when integers are expected.
✗ Incorrect
Both parameters should be of type int to add two integers.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
void as return type when a value is returned.Using different types for parameters.
✗ Incorrect
The function returns an int and both parameters are int types.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
int or double instead of float.Using
void as return type when a value is returned.✗ Incorrect
The function returns a float and both parameters are float to multiply decimal numbers.