PPL FIneL Flashcards
What is a function in C++?
A. A block of code that performs a specific task.
B. A data type for storing values.
C. A mechanism for memory allocation.
D. A library included in the program.
A block of code that performs a specific task.
What are the main components of a C++ function definition?
A. Function name, return type, parameters, and body.
B. Function name and the main() function.
C. Header files and variable declarations.
D. Only return type and parameters.
Function name, return type, parameters, and body.
What does the void keyword indicate in a function definition?
A. The function will always return an integer.
B. The function does not return a value.
C. The function must accept no arguments.
D. The function is predefined in the C++ library.
The function does not return a value.
When is a declared function executed?
A. As soon as the program starts.
B. Only after the function is called.
C. During the program compilation.
D. After the program terminates.
Only after the function is called.
What happens if a function is declared after the main() function?
A. It will execute before main().
B. An error will occur.
C. The program will ignore it.
D. The function will work normally.
An error will occur.
What is the term for a variable passed to a function?
A. Parameter
B. Argument
C. Constant
D. Pointer
Argument
Which keyword is used to return a value from a function?
A. return
B. void
C. break
D. exit
return
What is the correct syntax to call a function named myFunction with no parameters?
A. myFunction;
B. myFunction[];
C. myFunction();
D. call myFunction();
myFunction();
What must match between the function declaration and the function call when passing multiple parameters?
A. Only the number of parameters.
B. The order of parameters.
C. Both the number and order of parameters.
D. Neither number nor order of parameters.
Both the number and order of parameters.
How can a function’s result be stored?
A. It cannot be stored.
B. By assigning it to a variable.
C. By calling it without any arguments.
D. By declaring it as void.
By assigning it to a variable.
What is a predefined function in C++?
A. A function created by the user.
B. A function that is already defined in the C++ library.
C. A function without a return value.
D. A function that only operates on arrays.
A function that is already defined in the C++ library.
Which of the following is a valid function declaration in C++?
A. int myFunction();
B. void myFunction(int x, int y);
C. double calculateArea(double radius);
D. All of the above.
All of the above.
What is the primary purpose of functions in C++?
A. To reduce code duplication.
B. To increase the complexity of code.
C. To make code run faster.
D. To manage memory allocation.
To reduce code duplication.
What keyword is used to declare a function that does not return any value?
A. null
B. void
C. empty
D. none
void
In the function int add(int a, int b), what are a and b?
A. Arguments
B. Parameters
C. Local variables
D. Global variables
Parameters