Which return type should normally be used for a C++ function that does not return a value?
void display()
{
cout << "Hello";
}
Options
-
A.
int
-
B.
float
-
C.
void
-
D.
More than one of the above
-
E.
None of the above
Correct Answer (Detailed Explanation is Below)
C.
void
Detailed Explanation
Answer: (C) void
The void return type is used when a function does not return a value to its caller.
In the example, display() performs an operation by printing text but does not return a value.
Therefore, its return type is appropriately declared as void.