< Previous | Contents | Next >

The askNumber() Function

The askNumber() function gets an integer from the user. Although I only call it once in the program, its 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;

}

Summary 183