| CMPSC 101 - Functions Worksheet #6 | Name - |
1. Draw a rectangular console window in the area provided and show the expected output as precisely as possible.
#include
<iostream>
using namespace std;int addAFew(int);
void displayNum(int);int main( )
{
int number = 10;
while (number < 50)
{
number =addAFew( number);
}
displayNum(number);
return 0;
}int addAFew(int base)
{
return (base + 5);
}void displayNum(int aNumber)
{
cout << "The number is " << aNumber << endl;
}
2. Write a program that includes a function named checkNum. The program contains a loop that prompts the user to input an integer between or including 1 and 10. After the user has inputted a value, pass the value to the function checkNum. If the value is not between or including 1 and 10, the function should display the message "Try again". The loop in the main program should keep prompting the user to input a number until he has successfully inputted a number between or including 1 and 10. (You can assume that the user will not input floating-point values.)