Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Concepts tested by this program: 1.Learn to organize code within a function 2.Learn to pass data to and return Boolean data from function 3.Use

C++

Concepts tested by this program:

1.Learn to organize code within a function

2.Learn to pass data to and return Boolean data from function

3.Use of loop

4.Use file processing Program Prime Numbers

A prime number is an integer that is greater than 1 and that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6.

Write a function name isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demonstrate the function in a complete program that reads in an integer that is less than 3001 stores a list of all the prime numbers from 2 through that number in a file named "PrimeList.txt" and to the standard output.

-Primelist.txt file contents bellow:

2

3

5

7

11

13

17

19

23

Prime numbers written to Primelist.txt.

-Summary of what program has to do:

1. Ask the user "Insert integer number less than 3001."

2. If number is more than 3001 then a error should appear, if it is less, the number insterted will be there and also it will read the "PrimeList.txt" file which contains a list of numbers.

Screenshot: basically number 23 was inserted and the rest came from.txt

image text in transcribed

X CAUserslOwner Documents Visual Studio 20131Projects ConsoleApplication21\DebuglConsoleAp... CMSC 140 CRN xxxx Project 5: Prime Numbers *Written by a student Bill Morgan 04/03/2016 lould you please enter an integer number that should be less than 3001 23 2 19 23 Prime numbers written to PrimeList.txt Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions