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

  The examination room is freed

A doctor checks in by telling the scheduler his or her name, an examination room number, and a medical specialty code. Each doctor has a favorite room. The scheduler checks to see whether the room is free. If so, it assigns this doctor to the room; i..

  Write a program to make the ssds function

Write a program to make the SSDs function as a MM:SS real-time clock. Hint: You must not use a single delay routine for the one second delay because that will not allow for persistence of vision. The displays need to be constantly refreshed during ev..

  Write in simple basic c language

Prompt the user for 3 sentences of text. Pass these pieces of text into a function connect() which will connect all three sentences into one long sentence. Pass the combination sentence back to the main program, where it is printed.

  Write a number guessing game in which the computer selects

Write a number guessing game in which the computer selects a random number in the range of 0 to 100, and users get a maximum of 20 attempts to guess it.

  All the new strings generated

Explain why, if on some round, all the new strings generated for any syntactic category are longer than s, and s has not already been generated for L(), then s cannot ever be put in L(). Hint: Use Exercise 11.3.5.

  After the user presses any key

After the user presses any key, the board will be scrambled by making a large number of random moves (for a 3x3 puzzle, 100,000 attempted random moves in random directions will result in a sufficiently scrambled board)

  Create valle products accdb database file

Create a new table named Orders using the table design below. You may create your table in design view or datasheet view. Save the Orders table as Orders Your Name. Define a one-to-many relationship between the Customer table and Orders table. Ri..

  Prepare an arbitrary sinusoidal waveform

Create a program to compute the derivative of an arbitrary input function, with arbitrary duration and arbitrary limits

  Write a function that computes length of a character string

Write a function that computes the length of a character string (i.e. write your own implementation of the strlen function.

  Write a program to check whether a number is even or odd

Write a C++ program to check whether a number entered by user is even or odd.

  Write the pseudocode of the thread a and b

Suppose we have two threads A and B A and B repeatedly print out ping and pong, respectively We want to execute them in an alternating order An alternating execution would force A and B to print out in the order of ping pong ping pong ping pong Write..

  Write a recursive algorithm to print all of the subsets

Write a recursive algorithm to print all of the subsets for the set of the first positive integers.

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