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

  A sample issue-specific security policy for an organization

What is a mission statement. What is a vision statement. What is a values statement. Why are they important

  Create a weighted scoring model to determine grades

Create a weighted scoring model to determine grades for a course. Final grades are based on three exams worth 20 percent. 15 percent, and 25 percent.

  What other ways of writing privacy policies exist

What other ways of writing privacy policies exist? For example, are there useful ways to combine BMA and Chinese Wall

  Reverse the order of characters in a text file

Reverse the order of characters in a text file. For example, asdfghjkl becomes lkjhgfdsa.

  Discuss disaster recovery and business continuity

Identify and discuss the key differences between disaster recovery and business continuity

  Prepare and test an html document that describes nested list

Prepare and test an HTML document that describes nested ordered lists of cars. The outer list must have three entries: compact, midsize, and sports.

  Define a classes named ExamStatistics

CS160 - 01/02 Project - Examination Statistics Assignment. Design - For this project you shall define a classes named ExamStatistics

  Define the idea of a context as it relates to hci design

Interactive computer systems could be categorized both in terms of interaction styles and interaction paradigms. This helps us to understand the problems and potential value of any interactive system design. We must also pay attention to the conte..

  Write the xhtml to create a group of radio buttons

Write the XHTML to create a group of radio buttons that Web site visitors can check to vote for their favorite day of the week.

  Make a finite-state machine for a combination lock

Construct a finite-state machine for a combination lock that contains numbers 1 through 40 and that opens only when the correct combination, 10 right, 8 second.

  Can you alter the formatting so as this is printed multiples

Can you alter the formatting so as this is printed multiples it will be perfectly aligned as columns regardless of the size of the variables.

  Encode decoded sequence using the same initial dictionary

Encode the decoded sequence using the same initial dictionary. Does your answer match the sequence given above?

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