Create a program to find all the prime numbers between 1 and 100. One way to do
Question:
Create a program to find all the prime numbers between 1 and 100. One way to do this is to write a function that will check if a number is prime (i.e., see if the number can be divided by a prime number smaller than itself) using a vector of primes in order (so that if the vector is called primes, primes[0]==2, primes[1]==3, primes[2]==5, etc.). Then write a loop that goes from 1 to 100, checks each number to see if it is a prime, and stores each prime found in a vector. Write another loop that lists the primes you found. You might check your result by comparing your vector of prime numbers with primes. Consider 2 the first prime.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 75% (12 reviews)
note that different compilersSDEs keep header files in different places so th...View the full answer
Answered By
Harpreet Singh
I am currently persuing my bachelors in Mechanical Engineering with average of 80% scores.
As the matter of extra curricular activities is concerned. I do interest in Programming web development as well. I was a Google Code-In finalist in 2016 and
I have also worked recently on a reserch article named " An Outline on Modern Day Application on Solid Lubricants" going to be published in Materials Today Procedding (Elsevier) soon.
I completed my Diploma in mEchanical Enginnering in 2018 with 84% scores, and my matric from Teja Singh Sutantar Memorial Senior Secondary School back in 2015 with 90% scores.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
Write a program that displays all the prime numbers less than 120 in decreasing order. Use the StackOfIntegers class to store the prime numbers (e.g., 2, 3, 5,... ) and retrieve and display them in...
-
Write a user-defined function that finds all the prime numbers between two numbers m and n. Name the function pr=prime (m, n), where the input arguments m and n are positive integers and the output...
-
Modify Listing 5.15 to display all the prime numbers between 2 and 1,000, inclusive. Display eight prime numbers per line. Numbers are separated by exactly one space. Listing 5.15 1 public class...
-
Using the case study, characterize Amazons approach to marketing communications.
-
Wagtail Ltd uses the 'optimal batch size' model (see below) to determine optimal levels of raw materials. Material B is consumed at a steady, known rate over the company's planning horizon of one...
-
The speed of light in diamond is 1.24 10 8 m/s. The index of refraction of diamond is a. 1.24 b. 2.31 c. 2.42 d. 3.72
-
Longitudinal vibration of an isotropic, particle-reinforced composite bar may be modeled by using the 1D wave equation (Equation 8.99) if the material is linear elastic. Derive the equation of motion...
-
You have just been hired to the Senior Accountant position for Fitchtown LLC. During your first month in your new role, you will be completing a full accounting cycle for the month. You are the...
-
Ren, a sales representative of an Electric Supply Inc made a demo for a new high-speed Auto[1]analyzer for Glen, the owner of a car repair service shop. The price of the Auto-analyzer was $3,500.00....
-
On June 1, 2019, Kris Storey established an interior decorating business, Eco-Centric Designs. During the month, Kris completed the following transactions related to the business: June 1. Kris...
-
What are some operators that we can use for integers and floating-point values?
-
What operators can be used on integers but not on floating-point numbers?
-
Determine whether each infinite geometric series converges or diverges. If it converges, find its sum. 2 32 |
-
Company A is a wholesaler selling grocery goods to retail stores on credit. Company B is a manufacturing company selling its products to other manufacturers for use in their products. *Assume cost of...
-
Define a non-controllable cost.
-
Musical Productions Ltd, a client of your firm, has two divisions. The Compact Disc division (CD) assembles and markets portable compact disc players. The Portable Stereo division (PS) assembles and...
-
How are sales margin variances calculated.
-
Why is majority rule so popular when consensus decision making, by comparison, is often more advantageous?
-
Tomiko owns the copyright to several classic Motown songs. In 2014, he became aware that Tinseltown Records was selling several of his songs without his permission. He sues Tinseltown seeking...
-
What can scientists learn by comparing the fossilized skeletons of extinct primates with the bones of modern species?
-
Write a comparator for nonnegative integers that determines order based on the number of 1s in each integers binary expansion, so that i < j if the number of 1s in the binary representation of i is...
-
Explain how the k largest elements from an unordered collection of size n can be found in time O(nlogk) using O(k) auxiliary space.
-
Tamarindo Airlines wants to give a first-class upgrade coupon to their top logn frequent flyers, based on the number of miles accumulated, where n is the total number of the airlines frequent flyers....
-
Differentiate between a scalar value and a vector value.
-
Now that the supplier of the nori has been chosen and the transportation method selected, you turn your attention to the downstream side of the supply chain -- the marketing (distribution) channels....
-
Mandy Murphy, owner of Murphy and Co. (Saint John, New Brunswick), gave the following list of assets and liabilities to a public accountant and asked him to prepare a balance sheet for the company as...
Study smarter with the SolutionInn App