# programming

Document Sample

```					There are four problems I need done:

1. Write a void function that uses two nested for loops and the modulus (%) operator to detect
and print to standard output the first n prime integers. Recall that a prime number is a number
that is evenly divisible only by 1 and itself. Hint: the function prototype is: primeGen(int n);

2. Write a value returning function that prints the number of valid integer values contained in a
data file. If the file contains any data that cannot be read as an integer, the function should
return the number of integers that were successfully read prior to encountering the bad data,
and print a message to standard error indicating that not all of the data in the file could be read.
Hint: use the function header: int countInts (ifstream& file); and a precondition that file is
defined.

3. Write a program to determine the real roots of a quadratic equation, assuming that the user
enters the coefficients of the quadratic equation. If the roots are complex, print an appropriate
message.

4. The cosine of an angle can be computed from the following infinite series:
cos x = 1 - (x^2)/2! + (x^4)/4! - (x^6)/6! + ...
Write a program that reads an angle x (in radians) from the keyboard. Then, in a function,
compute the cosine of the angle using the first five terms of this series. Print the value computed
along with the value of the cosine computed using the C++ library function.

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 5 posted: 9/11/2012 language: Unknown pages: 1