Function parameters are variables listed in a function's definition. They act as placeholders for the values (arguments) passed to the function when it is called.
Click to reveal answer
beginner
How do you declare a function with two integer parameters in C?
You write the function name followed by parentheses containing the parameter types and names, for example:
void add(int a, int b) { /* code */ }
Click to reveal answer
beginner
What is the difference between parameters and arguments?
Parameters are the variables in the function definition. Arguments are the actual values you pass to the function when calling it.
Click to reveal answer
beginner
Can a function in C have no parameters? How?
Yes. You can declare a function with empty parentheses or with void inside, like void greet(void). This means the function takes no arguments.
Click to reveal answer
intermediate
What happens if you change a parameter value inside a function?
Changing a parameter inside a function only changes the local copy. The original variable passed as an argument outside the function stays the same.
Click to reveal answer
What keyword do you use to specify a function takes no parameters in C?
Anone
Bvoid
Cnull
Dempty
✗ Incorrect
In C, void inside the parentheses means the function takes no parameters.
If a function is declared as int sum(int x, int y), what are x and y?
AReturn values
BArguments
CParameters
DConstants
✗ Incorrect
x and y are parameters, placeholders for values passed when calling the function.
What happens to the original variable if you change a parameter inside a function?
AOriginal variable stays the same
BOriginal variable changes
CProgram crashes
DParameter changes outside the function
✗ Incorrect
Parameters are copies of arguments, so changing them inside the function does not affect the original variable.
How do you call a function named printMessage that takes no parameters?
AprintMessage(void);
BprintMessage{};
CprintMessage[];
DprintMessage();
✗ Incorrect
You call a function with empty parentheses if it takes no parameters.
Which of these is a correct function parameter list in C?
Aint a, float b
Bint a; float b;
C(int a, float b)
Dint a float b
✗ Incorrect
Parameters are listed by type and name separated by commas without parentheses or semicolons inside the list.
Explain what function parameters are and how they differ from arguments.
Think about the function definition versus the function call.
You got /3 concepts.
Describe what happens when you modify a parameter inside a function in C.
Consider how C handles data passed to functions.
You got /3 concepts.
Practice
(1/5)
1. What is the purpose of function parameters in C?
easy
A. To send data into functions so they can use it
B. To declare variables inside the main function
C. To print output on the screen
D. To create loops inside functions
Solution
Step 1: Understand function parameters
Function parameters allow you to pass information into a function so it can use that data.
Step 2: Identify the correct purpose
Creating loops inside functions, declaring variables inside the main function, and printing output on the screen describe other tasks, not the role of parameters.
Final Answer:
To send data into functions so they can use it -> Option A
Quick Check:
Function parameters = send data into functions [OK]
Hint: Parameters pass data into functions for flexibility [OK]
Common Mistakes:
Confusing parameters with variables declared inside main
Thinking parameters print output
Mixing parameters with loop control
2. Which of the following is the correct way to declare a function with two integer parameters in C?
easy
A. void add(int a; int b);
B. void add(int a, b);
C. void add(int a int b);
D. void add(int a, int b);
Solution
Step 1: Check parameter syntax
Parameters must be separated by commas and each must have a type and name.
Step 2: Identify correct syntax
void add(int a, int b); correctly uses commas and types. void add(int a; int b); uses semicolon instead of comma. void add(int a int b); misses comma. void add(int a, b); misses type for second parameter.
Final Answer:
void add(int a, int b); -> Option D
Quick Check:
Parameters need type and comma [OK]
Hint: Separate parameters with commas and specify type for each [OK]
Common Mistakes:
Using semicolons instead of commas between parameters
Omitting type for parameters
Missing commas between parameters
3. What will be the output of this C program?
void printSum(int x, int y) {
printf("%d\n", x + y);
}
int main() {
printSum(3, 4);
return 0;
}
medium
A. 7
B. 34
C. 0
D. Compilation error
Solution
Step 1: Understand function call and parameters
The function printSum receives 3 and 4 as parameters and adds them.
Step 2: Calculate the sum and output
3 + 4 equals 7, so printf prints 7 followed by a newline.
Final Answer:
7 -> Option A
Quick Check:
3 + 4 = 7 [OK]
Hint: Sum parameters inside function to get output [OK]
Common Mistakes:
Thinking parameters concatenate as strings
Expecting zero output without return
Assuming syntax error due to missing includes
4. Identify the error in this function declaration:
int multiply(int a, b) {
return a * b;
}
medium
A. Return statement is incorrect
B. Function must return void
C. Missing type for parameter b
D. Function name is invalid
Solution
Step 1: Check parameter declarations
Each parameter must have a type. Here, 'b' lacks a type.
Step 2: Confirm other parts are correct
Return type int and function name are valid. Return statement syntax is correct.
Final Answer:
Missing type for parameter b -> Option C
Quick Check:
Every parameter needs a type [OK]
Hint: Declare type for every parameter explicitly [OK]
Common Mistakes:
Omitting type for second or later parameters
Assuming return type must be void
Misreading return statement as error
5. You want to write a function that swaps two integers using pointers. Which function parameter list is correct?
hard
A. void swap(int &a, int &b)
B. void swap(int *a, int *b)
C. void swap(int a, int b)
D. void swap(int a*, int b*)
Solution
Step 1: Understand swapping with pointers
To swap values in C, you pass pointers to the variables so the function can modify original data.
Step 2: Identify correct pointer syntax
void swap(int *a, int *b) correctly declares two pointer parameters. void swap(int a, int b) passes by value (won't swap original). void swap(int &a, int &b) uses C++ reference syntax (invalid in C). void swap(int a*, int b*) has incorrect pointer syntax.
Final Answer:
void swap(int *a, int *b) -> Option B
Quick Check:
Use pointers to modify original variables [OK]
Hint: Use int * for pointer parameters to modify originals [OK]
Common Mistakes:
Passing parameters by value when pointers are needed
Using C++ reference syntax in C
Incorrect pointer declaration syntax
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.