Functions can be designed to simply perform a process. These functions return nothing and/or receive no arguments. Since void is a keyword used to designate something that is data type-less or undefined, it is used as the return type for functions that do not return a value. Furthermore, functions that do not return a value do not need to use the return keyword. If such a function wishes to end prematurely, it can do so using the return keyword without a data type, as in return;. Consider the following code:
#include <iostream> void SayHello(int NumberOfTimes) { for(int counter = 0; counter < NumberOfTimes; counter++) { std::cout<<"hello world "; } } void SayBye() { std::cout<<"\nbye\n"; return; } int main() { for(int counter = 0; counter < 10; counter++) { SayHello(5); } for(int counter = 0; counter < 10; counter++) { SayBye(); } return 0; }