C++ examples for Function:Function Creation
Doubles the user's number with a function
#include <iostream> using namespace std; int doub (int num); int main()/*w w w .j av a 2 s .c o m*/ { int number; int d_number; cout << "What number do you want doubled? "; cin >> number; d_number = doub(number); cout << number << " doubled is " << d_number; return 0; } int doub(int num) { int d_num; d_num = num * 2; return (d_num); }