C++program to find all prime n.o below 100 algorithm
Answers
Answered by
0
This c++ code prints out the following prime numbers: 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97.
But I don't think that's the way my book wants it to be written. It mentions something about square root of a number. So I did try changing my 2nd loop to for (int j=2; j
How would I need to change this code to the way my book wants it to be?
int main ()
{
for (int i=2; i<100; i++)
for (int j=2; j {
if (i % j == 0)
break;
else if (i == j+1)
cout << i << " ";
}
return 0;
}
Im not sure , cpyd frm google
But I don't think that's the way my book wants it to be written. It mentions something about square root of a number. So I did try changing my 2nd loop to for (int j=2; j
How would I need to change this code to the way my book wants it to be?
int main ()
{
for (int i=2; i<100; i++)
for (int j=2; j {
if (i % j == 0)
break;
else if (i == j+1)
cout << i << " ";
}
return 0;
}
Im not sure , cpyd frm google
Similar questions