C++ examples for Function:Function Return
Function return values can be used anywhere in the caller.
#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); }