Function parameters
#include <iostream>
#include <string>
using namespace std;
void printMessage(string, int);
int main ()
{
string name;
int age;
cout << "Enter name: ";
cin >> name;
cout << "Enter age: ";
cin >> age;
printMessage(name, age);
return 0;
}
void printMessage (string theName, int theAge)
{
cout << "Your name is " << theName
<< " and your age is " << theAge << endl;
}
Related examples in the same category