# Project #12870 - Functions and Stubs

1 Purpose
The purpose of this program is a transition into thinking about functions and and stubs of
functions. There are going to be three aspects to this program, a design document like we
did for previous programs, a program, and a record of your testing.

2 Procedure
1. Your task is to write a C++ program which performs one of three operations based
on the input values. Once again we will only input integers. All of the inputs will
be non-negative. This program will run in a loop, asking the user for values, making
computations, printing results, until the user inputs the sentinel value of -9999.

(a) Your program will prompt the user for a non-negative integer.
 This prompt and input WILL be done with a function.
 If the user inputs a negative value that is not the sentinel value you will
display the prompt again and read another value until either a non-negative
value is input or the sentinel value is input.
 This function will have no arguments (void).
 It will return an integer.
 Its prototype is exactly
int myPrompt( void );
 The return value will be either a non-negative integer or the sentinel value.

(b) If the user inputs a value from 10 to 50, then you will compute the sum of the
numbers between 1 and the input value.
 This computation WILL be done with a function
 This function will take as an argument a single integer
 It will return an integer.
 Its prototype is exactly
int mySum( int );

(c) If the user inputs a non-negative value less than 10, then you will compute
product of the values between 1 and the number.
 This computation WILL be done with a function
 This function will take as an argument a single integer
 It will return an integer.
 Its prototype is exactly
int myProd( int );

(d) If the user inputs a value greater than 50, then you will compute the remainder
of that value divided by 7.
 This computation WILL be done with a function
 This function will take as an argument a single integer
 It will return an integer.
 Its prototype is exactly
int myMod( int );

(e) Once you have made a computation, you will print the result. This print out
will be one of
1. The sum from 1 to 13 is 91
2. The product from 1 to 7 is 5040
3. The remainder of 68 / 7 is 5
 This output WILL be all generated by a function.
 This function will take as arguments two integers.
 It will return void.
 Its prototype is exactly
void myPrint( int, int );

(f) All of the function prototypes will be before main().

(g) There will be NO global variables. All the information the functions need or
supply will be in their arguments or return values.

(h) All of the function de nitions will occur after main().

output should be like this:

Enter a non-negative integer (-9999 to end): 8
The product from 1 to 8 is 40320
Enter a non-negative integer (-9999 to end): 9
The product from 1 to 9 is 362880
Enter a non-negative integer (-9999 to end): 10
The sum from 1 to 10 is 55
Enter a non-negative integer (-9999 to end): 11
The sum from 1 to 11 is 66
Enter a non-negative integer (-9999 to end): 12
The sum from 1 to 12 is 78
Enter a non-negative integer (-9999 to end): 13
The sum from 1 to 13 is 91
Enter a non-negative integer (-9999 to end): 50
The sum from 1 to 50 is 1275
Enter a non-negative integer (-9999 to end): 51
The remainder of 51 / 7 is 2
Enter a non-negative integer (-9999 to end): 52
The remainder of 52 / 7 is 3
Enter a non-negative integer (-9999 to end): -9878
Enter a non-negative integer (-9999 to end): 0
The product from 1 to 0 is 1
Enter a non-negative integer (-9999 to end): 1
The product from 1 to 1 is 1
Enter a non-negative integer (-9999 to end): 2
The product from 1 to 2 is 2
Enter a non-negative integer (-9999 to end): 3
The product from 1 to 3 is 6
Enter a non-negative integer (-9999 to end): -9999

 Subject Computer Due By (Pacific Time) 09/20/2013 11:00 pm
TutorRating
pallavi

Chat Now!

out of 1971 reviews
amosmm

Chat Now!

out of 766 reviews
PhyzKyd

Chat Now!

out of 1164 reviews
rajdeep77

Chat Now!

out of 721 reviews
sctys

Chat Now!

out of 1600 reviews

Chat Now!

out of 770 reviews
topnotcher

Chat Now!

out of 766 reviews
XXXIAO

Chat Now!

out of 680 reviews