In this problem you will write a C++ program to generate a list of all the the p
ID: 3531504 • Letter: I
Question
In this problem you will write a C++ program to generate a list of all the the prime numbers between a starting number and an ending number (inclusive).---------------------------------------------------------------------------for examples;==============================
Problem;Repeatedly ask for inputs until the start and stop numbers are greater than 0. Enter 2 positive numbers: -1 1, Enter 2 positive numbers: 0 0, Primes between 0 and 0: Print out a list of all prime numbers between the starting and stop numbers. Enter 2 positive numbers: 3 7, Primes between 3 and 7: 3 5 7 , Make sure it works regardless of input order. Enter 2 positive numbers: 7 3, Primes between 3 and 7: 3 5 7, Make sure it works for arbitrary start and stop inputs:, Enter 2 positive numbers: 10 30, Primes between 10 and 30: 11 13 17 19 23 29, ill rate 5 life saver. I use cin and cout and its C plus plus
Explanation / Answer
int num1;
int num2;
int numofvalues=0;
cout << "Enter starting number:";
cin >> num1;
cout<< "Enter ending number";
cin >>num2;
for(int start = num1; start<=num2; start++)
{
if(start%2==0)
{
numofvalues++;
}
}
cout << numofvalues << endl;
system("PAUSE");
return(0);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.