declare a void function without return value in C++
Code snippet on how to declare a void function without return value in C++
void noReturnValue(int num) {
int result = num * 5;
std::cout << result << std::endl;
}
This code declares a void function called ‘noReturnValue’, which takes an integer argument called ‘num’ and does not return any value. Inside the function, it multiplies the ‘num’ argument with 5 and prints the result on the console using the std::cout function which is part of the standard library. The std::endl indicates the end of the line. Since the function is void, it does not return anything but simply prints the result using the std::cout.