Problem 1: [7 points]
A subnumber of a positive integer n is any positive integer whose
digits occur consecutively, in the same order, in n.
For example, 54 is a subnumber of 39543 since the digits 5 and 4 occur
consecutively, in the same order, in 39543.
Some other examples of subnumbers of 39543 are 395, 9543, and 5.
The set of all 2-digit subnumbers of 39543 is .
Write a function called sumSubnum that takes in a long int parameter n and produces as output the sum of the 2-digit subnumbers of n. For example, if n equals 39543, then sumSubnum might produce as output:
The sum of the 2-digit subnumbers is 231
Use the following function header:
void sumSubnum(long int n)
Note: You are not being asked to write a program, just the function.
Hint: Use the modulus operator % and the division operator / repeatedly.
Problem 2: [7 points]
Write a function that starts by asking the user whether she would like to type a positive integer as input. The user is expected to respond by typing YES or NO. If the user types NO, the program immediately terminates. However, if the user types YES, then the program prompts the user for a positive integer. The program then reads the integer, say n, that the user types and computes and displays the sum of all the 2-digit subnumbers of n. The program does this by calling the function sumSubnum defined above in Problem 1. Then the program repeats the entire process by asking the user whether she would like to type a positive integer as input.
Note: You may assume that the user types either YES or NO and nothing else in response to whether she would like to type in a positive integer. Furthermore, you may also assume that the user always types in a positive integer when prompted for one.
Problem 3: [6 points]
Problems 3.5, 3.6, 3.7, and 3.10 from the Pause to reflect section on pages 94 and 95.