Modify the program to allow the user to enter the range

Assignment Help Computer Engineering
Reference no: EM132158157

Use the isPrime function that you wrote in Programming Challenge 22 in a program that stores a list of all the prime numbers from 1 through 100 in a file.

Modify the program to allow the user to enter the range (both smallest and largest value) to be considered as well as the desired output file name.

The output file should be space delimited.

Provide a flowchart for the isPrime function.

This is what I have,

#include <iostream>
#include <fstream>
using namespace std;

bool isPrime(int);

int main()
{
int num=0;
int i;
bool prime;

ofstream outFile;
outFile.open("PrimeList.txt");


while(num == 0)
{
cin >> num;
}


for(i=2;i<num;i++)
if(isPrime(i))
outFile << i << "\n";


cout << "Prime numbers written to PrimeList.txt.\n";
outFile.close();
return 0;
}
bool isPrime(int n)
{
int i;
for(i=2;i<n-1;i++)
if(n%i==0)
return false;
return true;
}

Reference no: EM132158157

Questions Cloud

Convert both ways with one textfield and one button : Design a graphical user interface (GUI) to show the conversion. For instance be able to convert both ways with one textfield and one button.
Coding sequence for the first amino acid methionine : The M1V mutation changes the coding sequence for the first amino acid methionine of FBN-1 to valine.
Sds gel electrophoresis revealed two samples : If your SDS gel electrophoresis revealed two samples with the same denatured molecular weight
Make a program to hold three test scores : The class should have accessor and mutator methods for the test score fields and method that returns the average of the test scores.
Modify the program to allow the user to enter the range : Use the isPrime function that you wrote in Programming Challenge 22 in a program that stores a list of all the prime numbers from 1 through 100 in a file.
Forms of division in humans : Cells are capable of one of two forms of division in humans. The form of division that can introduce our inherited traits is meiosis.
Underwings with a true-breeding female leafhopper : In this case you are crossing a male leafhopper with red underwings with a true-breeding female leafhopper with blue underwings.
Design and code a software program that implements : Design and code a software program that implements a restaurant cashier that takes payments and collects and sums up the customer bill.
What would you do to analyze the situation : Use the five-step decision-making process discussed in Chapter 1 to analyze the following situations and recommend a course of action.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd