Find all the prime numbers between 90,000 and 100,000

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

Prime Numbers?

You are to find all the prime numbers between 90,000 and 100,000 and print them out.

One way to do this (the way you will have to do this) is fill an array with the values from 1 to 100,000. Start with 2 and go thru the array and every 2nd location in the array zero it out. You just eliminated any value that is divisible by 2. Now move to the next value (after 2) which will be 3, and go thru the array and zero out every 3rd location of the array. You just eliminated any number divisible by 3. Now move to the next location after 3 which is 4, and you see it is zero. Skip it because you have eliminated all multiples of 4 by eliminating multiples of 2. So move to the next (5) and eliminate multiples of 5. (Be sure not to zero out the 2,3 and 5 etc since they are prime numbers, just their multiples.) So if the next location is not 0, then traverse through the array and eliminate its multiples. Do this for the entire array.

You do not have to loop from 1 to 100,000. Find what value you can stop at in this algorithm which is much less than 100,000.

Print out the nonzero values in the array and that will be the prime numbers. Print out the numbers 7 per line and make sure they line up on the last digit. (setw(8)???)

You are to use an array for the data and use pointers to move through the array to solve this problem. The only place to use the [ ] is in the declaration, no [ ] syntax in any other code in the program.

Attachment:- prime.cpp

Reference no: EM13936629

Questions Cloud

What is the number of observations used for each variable : State your conclusions relative to the assumptions. What is the number of observations used for each  variable? How did you handle missing data? What is the value of the Pearson correlation coefficient between these two variables? In SPSS, useAnalyze..
Managed or developed in a global context : The purpose of the project is to apply the knowledge and techniques you learn from this class to study real world problems. You will need to research a specific topic in the context of global IT management And write a 6 page paper.
Find potential hazards that impact stability of ecosystem : Identify the structure and function of the main organs in at least two of the organisms found in your selected ecosystem, and indicate why they are best suited for that environment.
Future of professional communication : Your blog should respond (in total) to any four of these headings: • The future of professional communication.
Find all the prime numbers between 90,000 and 100,000 : Print out the nonzero values in the array and that will be the prime numbers. Print out the numbers 7 per line and make sure they line up on the last digit. (setw(8)???)
Evaluate the pirellis performance : Calculate Pirelli's bonus for 2008. Evaluate Pirelli's performance. Did he do as good a job as the numbers in requirement 1 suggest? Explain.
With the latest threats and security issues : Security professionals need to ensure that they keep up to date with the latest threats and security issues. This allows them to update their risk profiles, such as identifying if their systems are vulnerable.
What leading primary producers and top consumers ecosystem : What are the consequences if all individuals belonging to one of these key species are removed? (Choose one specific example and describe the impact on other organisms in the ecosystem as well as on the abiotic environment.)
Calculates and displays the body mass index : Write a Java application that calculates and displays the body mass index (BMI) for N people. N should be declared as a constant and should be equal to the largest digit of your student id number

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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