Functions
1. What is the correct way to declare a function in C++?
-
A. function int add(int a, int b);
-
B. int add(int a, int b);
-
C. void add(int a, int b);
-
D. add(int a, int b);
int add(int a, int b);
int add(int a, int b);
2. Which of the following is the correct definition of a recursive function in C++?
-
A. A function that calls another function.
-
B. A function that returns an integer value.
-
C. A function that calls itself.
-
D. A function that doesn't return any value.
A function that calls itself.
A function that calls itself.
3. In C++, which of the following is true about default function arguments?
-
A. Default arguments must be provided in the function definition.
-
B. Default arguments must be provided in the function declaration.
-
C. Default arguments can only be used with void functions.
-
D. Default arguments must be given in the function call.
Default arguments must be provided in the function declaration.
Default arguments must be provided in the function declaration.
4.What will happen if you call a function without providing an argument for a parameter that has a default value?
-
A. A compile-time error will occur.
-
B. The default value will be used for that parameter.
-
C. The program will terminate.
-
D. It will cause an infinite loop.
The default value will be used for that parameter.
The default value will be used for that parameter.
5.Which of the following is the correct syntax for calling a function in C++?
-
A. add(5, 6);
-
B. int add(5, 6);
-
C. call add(5, 6);
-
D. function add(5, 6);
add(5, 6);
add(5, 6);