Write a driver program with a main method

Assignment Help C/C++ Programming
Reference no: EM132103237

A prime number is an integer that is evenly divisible only by 1 and itself. For example, the only integers that divide 7 evenly are 1 and 7, thus 7 is a prime number.

On the other hand, a number that is not prime is said to be composite. An integer n is composite if there exist integers a and b such that n = ab, with 1 < a < n, and 1 < b < n. For example, the number 24 is composite since it can be factored in the following ways: 24 = 2 X 12, 24 = 3 X 8, and 24 = 4 X 6, with other factorizations possible, including 24 = 1 X 24 (but not only this way).

Write a method named isPrime, which takes an integer as an argument and returns true if the argument is prime or false otherwise. Write a driver program with a main method that calls the isPrime method to demonstrate that it works.

Finally, modify your program so that it makes use of the isPrime method to store a list of all the prime numbers from 1 to 100 in a text file.

The list should look like the following:

2

3

5

.

.

.

97

Reference no: EM132103237

Questions Cloud

What tactics she can use to get a higher ranking : She also wants to know if she should start a paid ad campaign on Google too. What advice would you give her?
Calculate the final purchase price after discount : At the President's Day sale, a customer can bring in a coupon for a 10%, 20% or 30% discount off of total purchases.
Determine the value of the function pn for different value : Write a program to determine the value of the function P(n) for different values of n. The first few prime sums are 2, 5, 10, 17, 28, 41, 58 and 77.
What advice would you give her : Pretend that you are a SEO consultant hired by a new home baker who is planning on selling her products thorough the internet.
Write a driver program with a main method : Write a method named isPrime, which takes an integer as an argument and returns true if the argument is prime or false otherwise.
Write your solution using dynamically allocated arrays : Even though this assignment can be coded with statically allocated arrays, please write your solution using dynamically allocated arrays.
How can you print three rows of values on an lcd : How can you print three rows of values on an LCD using mbed at the same time for example time, date and year.
Test your methods within a class and check : Test your methods within a class and check that they work properly. Use the method prime(int n) in the implementation of the other 2 methods.
Create an array of bool values that are true for all prime : Create an array of bool values that are true for all prime numbers but are false otherwise. Initially set all of the array entries to true.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Implement the value iteration algorithm for mdp

CSCI924/CSCI424 - Reasoning and Learning - Implement the value iteration algorithm for MDP which computes the solution to the situation. You may write your code in either C or C++. Your code must be implemented as a self-contained single source co..

  Create a program that outputs the result of the formula

Create a program that uses the same formula above to output the result; this time, however, prompt the user for the values a, b, x, and y. Use appropriate variable names and naming conventions.

  The conversion of binary numbers to decimal numbers

You will need to use a for() loop to process the eight bits. You will need to use a while() loop to access the numbers in the data file (checking for the end of file). This program will help you read data from a data file, valid the data and proce..

  Suitable examples using the basic operations

Briefly review Regular Expressions - the notation and the languages they represent with suitable examples using the basic operations - namely, concatenation, union , Kleene Closure.

  Create a version of the game battleship

The project is to create a version of the game Battleship where the user plays the computer. I will hold you to high standards for this project.

  What action would you like to implement

Create a Students class with the following methods: default constructor, overloaded constructor, copy constructor, setMaxNumberOf Students, add5tudent, addCours

  Squares, triangles, circles and ellipses

write a program which will answer a pair of questions for squares, triangles, circles and ellipses. A square is defined by its lower left corner ( S L L x , S L L y ), and the length of one side  S W .

  Implement a cardiac machine simulator in c++

keep track of the bug location; which could be an index into the memory array. Watch out for cells 0 and 99; they are special.

  Definition of the member functions to implement class

Write the definition of the member functions to implement the operations for this class. Also, write a program to test various operations on this class.

  Create an app that will play an audio file backwards

Your group has been tasked with creating an app that will play an audio file backwards - Because this app is likely to be used on a mobile device, your group figures that this algorithm should use as little memory and space as possible.

  Write down a c program to generate a matrix of integers

Write down a C program to generate a matrix (2-D Array) of integers in the range 1 to 100.

  Wap to calculate the area of the circle

Write a C++ program that prompts the user for the radius of a circle, then calls inline function circle Area to calculate the area of that circle.

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