0% found this document useful (0 votes)
7 views2 pages

Function RQ

The document contains review questions for a Programming Fundamentals course focusing on C++ concepts. It covers topics such as function prototypes, valid function declarations, return types, parameter passing methods, function overloading, variable scope, inline functions, default arguments, and recursive functions. Each question provides multiple-choice answers to test understanding of these programming fundamentals.

Uploaded by

anwaralye2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Function RQ

The document contains review questions for a Programming Fundamentals course focusing on C++ concepts. It covers topics such as function prototypes, valid function declarations, return types, parameter passing methods, function overloading, variable scope, inline functions, default arguments, and recursive functions. Each question provides multiple-choice answers to test understanding of these programming fundamentals.

Uploaded by

anwaralye2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CPU Business and Information Technology College

Programming Fundamentals
Review Questions
1. What is the purpose of a function prototype in C++?
a) To define the function
b) To declare the function before it's defined
c) To call the function
d) To allocate memory for the function
2. Which of the following is a valid function declaration?
a) `int myFunction(int a, b);`
b) `myFunction(int a, int b);`
c) `int myFunction(int a, int b);`
d) `int myFunction(int a, int b) {}`
3. What does the `void` keyword indicate when used as a return type?
a) The function returns an integer
b) The function returns no value
c) The function takes no parameters
d) The function is invalid
4. What is the output of this code?
#include <iostream>
using namespace std;
void modify(int x) {
x = x * 2;
}

int main() {
int num = 5;
modify(num);
cout << num;
return 0;
}
```
a) 5
b) 10
c) 0
d) Compilation error
5. Which parameter passing method allows a function to modify the original variable?
a) Pass by value
b) Pass by reference
c) Pass by constant reference
d) Pass by copy
6. What is function overloading?
a) Using the same function name with different return types
b) Using the same function name with different parameter lists
c) Calling a function too many times
d) Making a function too complex
7. What happens if a non-void function doesn't return a value?
a) It returns 0 by default
b) It returns a random value
c) It causes a compilation error
d) It returns void
8. What is the scope of variables declared inside a function?
a) Global scope
b) File scope
c) Local scope
d) Class scope
9. What does the `inline` keyword suggest to the compiler?
a) To make the function recursive
b) To insert the function code directly where called
c) To make the function virtual
d) To export the function from a library
10. Which is true about default arguments?
a) They must be the first parameters in the parameter list
b) They must be the last parameters in the parameter list
c) They can be placed anywhere in the parameter list
d) They are not allowed in C++
11. What is a recursive function?
a) A function that calls other functions
b) A function that calls itself
c) A function that never returns
d) A function with many parameters

You might also like