C++ Function Return values can be used anywhere in the caller

Description

C++ Function Return values can be used anywhere in the caller

#include <iostream>
using namespace std;
int doub(int num); 
int main()// w  w w.j av a 2 s  . co  m
{
   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); 
}



PreviousNext

Related