1Terminates the execution of a function and returns control to the calling function (or to the operating system if you transfer control from the main function). Execution resumes in the calling function at the point immediately following the call
1void printChars(char c, int count) {
2 for (int i=0; i<count; i++) {
3 cout << c;
4 }//end for
5
6 return; // Optional because it's a void function
7}//end printChars
8
1// Multiple return statements often increase complexity.
2int max(int a, int b) {
3 if (a > b) {
4 return a;
5 } else {
6 return b;
7 }
8}//end max
9
1// Single return at end often improves readability.
2int max(int a, int b) {
3 int maxval;
4 if (a > b) {
5 maxval = a;
6 } else {
7 maxval = b;
8 }
9 return maxval;
10}//end max
11