Introduction to Functions


//intro to functions
//function_intro.cpp


#include <iostream> 
using namespace std;

int getnum();					//function prototype
								//tell C++ there'll be a function later
								//that's called getnum.

int main()
{
	int num1, num2, num3, num4;		//declare integers

	num1 = getnum();		//get all variables assigned through function
	num2 = getnum();
	num3 = getnum();
	num4 = getnum();

	cout << "The numbers you entered are: \n" ;
	cout << num1 << "  " <<< "  " << num3 << "  " << num4 << endl << endl;

	return 0;

} //end of main function

//get_num function
int getnum()
{
	int number;
	cout << "\nEnter a number, please \n";
	cin  >> number;
	return number;
}