Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Void Return Type | Function Return Values Specification
C++ Functions

Void Return TypeVoid Return Type

In C++, the void return type is used in functions to indicate that the function does not return any value. When a function has a void return type, it means the function does its task without producing a result that needs to be used elsewhere in the program.

For example, let's consider the function that prints values of 1D dynamic array that we used before:

cpp

main.cpp

We can see that the purpose of this function is to print the array, and it doesn't produce any meaningful result that must be returned. So we can use void return value in this case.

But you can still use return in a void function. For example if you want to terminate it on certain condition.

cpp

main.cpp

Which of the following statements is true about a function with a void return type?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 4
course content

Зміст курсу

C++ Functions

Void Return TypeVoid Return Type

In C++, the void return type is used in functions to indicate that the function does not return any value. When a function has a void return type, it means the function does its task without producing a result that needs to be used elsewhere in the program.

For example, let's consider the function that prints values of 1D dynamic array that we used before:

cpp

main.cpp

We can see that the purpose of this function is to print the array, and it doesn't produce any meaningful result that must be returned. So we can use void return value in this case.

But you can still use return in a void function. For example if you want to terminate it on certain condition.

cpp

main.cpp

Which of the following statements is true about a function with a void return type?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 4
some-alt