Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that finds and prints all of the prime numbers between 10 and 20

ID: 3649105 • Letter: W

Question

Write a program that finds and prints all of the prime numbers between 10 and 200. A prime number is a number such that 1 and itself are the only numbers that evenly divide it (for example, 11, 13, 17...). One way to solve this problem is to use a doubly nested loop. The outer loop can iterate from 10 to 200 while the inner loop checks to see if the counter value for the outer loop is prime. One way to see if number n is prime is to loop from 2 to n -1 and if any of these numbers evenly divides n, then n cannot be prime, if none of the values from 2 to n -1 evenly divides n, then n must be prime. (Note that there are several easy ways to make this algorithm more efficient.)

Explanation / Answer

please rate - thanks

#include <iostream>
using namespace std;
int main()
{int i,j,factors;
cout<<"prime numbers between 10 and 200 ";
for(j=10;j<=200;j++)
{factors=0;
   for(i=2;i<j;i++)
     if(j%i==0)
        i=j+1;
   if(i==j)
        cout<<j<<" ";           
   }
cout<<endl;
system("pause");
return 0;
}


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote