Which C++ statement is a function declaration rather than a function definition or function call?
5 Functions Online Quiz Questions
Use this free practice quiz with 20 questions to review 5 Functions, test your knowledge, and prepare for your next test or exam.
True or false: A C++ function with return type void does not return a value to its caller.
- A
True
- B
False
In the call add(4, 7), what is the C++ term for each value supplied to the function?
A variable declared inside an if block can be used only within that block. This limitation is called .
What is the value of value after this program runs?
void try_to_change(int number) { number = 99; }
int value = 10;
try_to_change(value);
- A
valueremains10 - B
valuebecomes99 - C
The program fails because assignment to a parameter is illegal
- D
valueis destroyed when the function returns
Which benefits can result from decomposing a program into several focused functions? Select all that apply.
- A
Each function can be read independently, reducing complexity.
- B
A calculation can be called from several places, encouraging reuse.
- C
Functions no longer need parameters.
- D
Individual functions can be tested with known inputs.
- E
Changing one calculation always requires rewriting input and output code.
What C++ feature allows functions in the same scope to have the same name while differing in their parameter lists?
True or false: A parameter declared for one function can normally be used directly in main because parameters have program-wide scope.
- A
True
- B
False
A function declaration introduces a function without its body. The version that supplies the body is called a .
A task needs to produce several results. Which approaches are identified as reasonable introductory solutions? Select all that apply.
- A
Return a class or structure containing the results.
- B
Modify objects through reference parameters.
- C
Decompose the task into multiple functions.
- D
Change only the function's return type while keeping its parameter list identical.
- E
Use a
voidreturn type and assume the caller automatically receives all local variables.
Given these overloads, which one is selected by the call maximum(3, 8)?
int maximum(int a, int b);
double maximum(double a, double b);
- A
maximum(int, int) - B
maximum(double, double) - C
Both overloads are equally preferred
- D
Neither overload is viable because
maximumis overloaded
Design a function decomposition for a program that reads a rectangle's length and width, calculates its area, and prints the result. Describe the responsibility and relevant inputs or result of each function.
What is wrong with this C++ code?
int add(int, int);
int add(int a) { return a; }
- A
The function name must be capitalized.
- B
The return type must be
void. - C
The declaration and definition describe different parameter lists.
- D
A function cannot be defined after it is declared.
True or false: The body of a C++ function contains the statements that implement the function's task.
- A
True
- B
False
Which part of a C++ function definition supplies the implementation of the function?
- A
The function body
- B
The parameter list
- C
The return type
- D
The function name
In the call add(4, 7), what C++ term describes each supplied value, such as 4 or 7?
A source file defines int add(int first, int second) { return first + second; }. Which declaration correctly matches that definition?
- A
void add(int); - B
int add(int, int); - C
double add(double, double); - D
int add();
Given the function double half(int value) { return value / 2.0; }, what value does half(5) return?
- A
2
- B
2.5
- C
3
- D
5
Consider int difference(int a, int b) { int result = a - b; return result; }. Which statement correctly describes where the name result can be used?
- A
resultcan be used anywhere afterdifferenceis called. - B
resultis available inmainbecause it is returned. - C
resultcan be used only insidedifference. - D
resultis a global variable because it has aninttype.
What numeric value is returned by half(5) when half is defined as double half(int value) { return value / 2.0; }?
Related study packs and tools
2 Digital Logic
A 14-question medium-difficulty quiz on Boolean algebra, logic gates, truth tables, and combinational circuits.
03 — Python Programming Fundamentals
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
04 Conditionals and Boolean Logic
Learn how Boolean expressions, logical operators, and conditional structures let programs make reliable decisions, including how to handle boundaries, branch order, and testing.
6 Computer Memory
Learn how computer memory stores and addresses information, how RAM and ROM differ, and how caches and the memory hierarchy balance speed, capacity, and cost.
07 Trees and Binary Search Trees
A progressive guide to tree structure, binary-tree traversals, binary search tree operations, deletion, balancing, and the way tree height determines time and space costs.
12 — Foundations Capstone: Integrating Computer Science
A practical guide to integrating problem definition, data representation, modular programming, algorithms, complexity analysis, testing, correctness, and ethical evaluation into a responsible computer science capstone.
Interrupts
Reviews how interrupts support event handling and multitasking, and how Linux system calls use the RISC-V `ecall` instruction and register conventions.
OS Processes
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.
Systemcalls
A quiz on operating-system system calls, including privileged-operation requests, process creation and execution with fork, exec, and waitpid, and signal handling.