| Lexington High School Mathematics | Math Dept. Front Page | Student Links | Family Links |
| Introduction to C++, Kevin Kelly | Kelly Front Page | C++ Course Guide | C++ Assignments | C++ Info |
Write a program that prints a list of all the prime numbers between 1 and 1000. Your program must use the prime function that you wrote for Assignment 22.
To get started, you might want to copy your file from the previous assignment by typing something like this at the UNIX prompt:
cp a22.cpp a23.cppThen you'll just have to write a new main function.
Please do not print each prime number on its own separate line, as this would take hundreds of lines and use lots of paper. A list separated by commas would be a better idea; the beginning of the output would look like:
2, 3, 5, 7, 11, 13, ...
For 10 points: In addition to all the above, also write a separate program that determines the answer to this question: "How many prime numbers are there between 1,000,000 and 2,000,000?"