< Previous | Contents | Next >
The askNumber() function gets an integer from the user. Although I only call it once in the program, it’s versatile because it takes a parameter of type string that it uses to prompt the user.
int askNumber(string prompt)
{
int num;
cout << prompt; cin >> num; return num;
}