Assignment H

Use the lab instructions given on the Internet at http://voyager.deanza.edu/~oldham
Use the same format for the opening comments as in assignment A, with your name, course and quarter, assignment, problem, and short problem description.
Type a program, as described in the following description. Compile it, correct any errors and execute it.
Copy the execution results into an   /* Execution Results:   comment.
Print the completed program with the execution results from within the Interactive Development Environment.
Always use memory constants when constant values are needed, except numbers such as 0 or 1 can be used in the code where their use is clear. Use functions when ever possible, in each problem.
Provide a function prototype for each function before the main function.
The function prototype should have descriptive names for the function and for each parameter.
Put very little code in the main function.
Each function should be preceded with a short comment giving:

Chapter 6 problem 50

In this problem you will build a main function, that acts as a test driver for your theta (Θ) function.
In the figure in the book for problem 50, theta (Θ) is used for the approximation of pi (Π).

Definition of a Test Driver:

When you write a function, it is good practice to test the function before you try to use it in a project.
To test your function you can write a simple main function that serves as a test driver.
Often test drivers are thrown away after use, or may be kept to test your function again when you modify the function.
After you have tested your theta function, you can use your theta function whenever you need it.

Make the return type from the theta function a double, the value of theta.
Make the parameter of the theta function an int, the number of terms to be used in the approximation.

Call the theta function from main two times.
The first time, pass the integer 5 to request 5 terms in the approximation.
The second time, pass the integer 10 to request 10 terms in the approximation.
In the main function print a neat listing of the results.
First print the value of pi (which is approximatly 3.141592653589793),
Then print the following for each of the two passes:

Problem H1

Write a program which has two functions, the main function and the input function.
The input function asks the user to enter an integer from 0 to 100, inclusive.
In the input function:

Hints:
You might use a do...while loop in the main function, that runs as long as -1 is not returned.
You might use a do...while loop in the input function, that loops as long as the user enters a number that is out of the required range.
Make sure your program does not confuse the datum -1 with EOF, which is also -1
Only code one return from each function.

Test data: use each of the following values: 100 101 20 -5 0 9 -1 18

The main function should print 100 20 0 9 18 and a run completed message.