This program requires you to write and use some functions, and answer some quiz questions. Part 0 Write a function that prompts the user to enter a line length. If a -99 is entered, then return to the caller the total number of lines printed; otherwise, print an error message if the entered value is less than 0 or greater than 80. If the entered number is between 0 and 80, then prompt the user to enter a character. Print a line using the entered character having a length equal to the entered line length. At most 10 lines can be printed. This value is passed as an argument to the function. Part 1 Write a function that prompts the user to enter two characters. If the user enters a tilde character (~), then return the number of results printed. Otherwise, print a message indicating which character is bigger and which character is smaller. At most 10 results can be printed. This value is passed as an argument to the function. In addition, the sentinel value for this part (i.e. the tilde) is also passed as an argument to the function. Part 2 Write a function that prints the answers to the following questions. There should be only one answer per line. Each answer must be prefixed with the question number followed by a closing (i.e. right) parenthesis. The function returns the number of lines printed. What will the following code snippet print? double d = 10.0; int result = d / 3; cout << result; What will the following code snippet print? int i = 1, j = 2, k = 3; if (i && j == 2 || k) cout << "hello"; else if (!i && !(k == 3)) cout << "Hello"; cout << " world"; What will the following code snippet print? int k=10;k++;++k;k++;if(k<=13)cout<<"yes";else cout <<"no"; How many times will the following loop print the string "foo"? for (int i = 1000; i > 0; i %= 10) cout << "foo" << endl; What value will be assigned to the variable 'i'? int a = 5, b = 10; int i = ((a != b) && (b > 0) && (a <= b)) ? (b * a) : (b - a); Part 3 Prior to ending the program, print the total number of lines printed by all of the functions used in the program. This value does not include heading lines, error messages, and prompts.
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Notes All prompts and error messages must be written to the standard error stream. Here are function prototypes you can use. int printQuiz(void); int printLines(int maxLines); int compareChars(int maxResults, char sentinelValue); The body of your main() function may look something like the following. int nLines = 0; // count total number of lines printed int partNbr = 0; // print heading for each Part printed printPartHeading(partNbr++); nLines += printLines(MAX_LINES); printPartHeading(partNbr++); nLines += compareChars(MAX_RESULTS, PART1_SENTINEL_VALUE); printPartHeading(partNbr++); nLines += printQuiz(); printPartHeading(partNbr++); cout << "Total number of lines printed: " << nLines << endl; return EXIT_SUCCESS; // MAX_LINES, MAX_RESULTS, PART1_SENTINEL_VALUE are // programmer defined manifest constants. You do not have to write the function printPartHeading(); however, one extra credit point will be awarded if you do. Output The output of program does not need to include the prompts. The prompts are provided to help give you an idea as to how the program looks from a user's perspective. For documentation purposes, user inputs are enclosed in brackets < > ------ Part 0 ------ Enter a length (-99 to exit this part): <10> Enter a character: <=> ========== Enter a length (-99 to exit this part): <5> Enter a character: <:> ::::: Enter a length (-99 to exit this part): <-1> *** error: -1 is invalid input Enter a length (-99 to exit this part): <-99> ------ Part 1 ------ Enter character number 1 (~ to exit this part): <)> Enter character number 2 (~ to exit this part): <(> ) is greater than ( Enter character number 1 (~ to exit this part): <+> Enter character number 2 (~ to exit this part): <9> 9 is greater than + Enter character number 1 (~ to exit this part): <9> Enter character number 2 (~ to exit this part): <{> { is greater than 9 Enter character number 1 (~ to exit this part): <~> ------ Part 2 ------ 1) 5 2) hello world 3) yes 4) 3 5) 10 ------ Part 3 ------ Total number of lines printed: 10
## Platform
windows xp