76 249
Assignments Done
Successfully Done
In May 2019

Answer to Question #16317 in C++ for airi

Question #16317
2. a prime integer number is one that has exactly two different divisors, namely 1 and the number itself. Write, run and test a c++ program that finds all the prime numbers less than 100. (hint. 1 is a prime number. for each number from 2 to 100, find remainder = number % n, where n ranges from 2 to sqrt(number). if n is greater than sqrt (number), the number is not equally divisible by n. why? if any remainder equals 0, the number is not a prime number.
Expert's answer
using namespace std;

int isprime(int valuex){
int x,j;
& for (j=2 ; j<valuex; j++)
{ if ((valuex%j)==0) x=0; }
& if(x!=0) return 1;
& else return 0;

void main(){
for (int i=1; i<101; i++)
& if (isprime(i)) cout<<i<<"\n";

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions