Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program #1-Finding Prime Numbers This program asks you to determine a set of prime numbers, given some input from the user. Your program should ask
Program #1-Finding Prime Numbers This program asks you to determine a set of prime numbers, given some input from the user. Your program should ask the user to enter an integer between 1 and 100. For purposes of discussion, let's call that number num. If num is outside that range, your program should print out an error message and re-prompt for another number (i.e., have an input validation loop) Your program should then calculate the first num prime numbers and print them both to the screen and to an output file, PrimeOut.txt. Your output should be neatly formatted, 10 numbers per line, and should look like the following examples. For the first example, let's assume num-20 The first 20 primes: 2 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 6771 or ifnum 25: The first 25 primes: 7 11 13 17 19 2329 31 37 41 43 47 53 59 6 6771 2 73 7983 89 97 Here we are using a 5 byte field just as we did in a previous assignment. Since the 100th prime is a three digit number, that should work well. (Other spacing's are obviously possible; just make sure there are 10 numbers per line.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started