Function return values can be used anywhere in the caller. - C++ Function

C++ examples for Function:Function Return

Description

Function return values can be used anywhere in the caller.

Demo Code

#include <iostream>
using namespace std;
int doub(int num); 
int main()/*from   w  w w .  j a  v  a2 s. c  om*/
{
   int number;     
   cout << "What number do you want doubled? ";
   cin >> number;
   cout << number << " doubled is " << doub(number);
   return 0;
}
int doub(int num)
{
   int d_num;
   d_num = num * 2;
   return (d_num); 
}

Result


Related Tutorials