please help with this code. the only error is i want to print 8numbers per line
ID: 3613382 • Letter: P
Question
please help with this code. the only error is i want to print 8numbers per line , but i don't know what is the problem.#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int number = 2 ;
while(number <= 1000)
{
bool prime = true;
for(int nums = 2 ; nums <= number / 2; nums++)
{
if(number % nums == 0)
{
prime = false;
}
}
if(prime)
{
if(number % 8 == 0)
{
cout << number <<endl;
}
else
{
cout << number <<" ";
}
}
number++;
}
system("pause");
return 0;
}
Explanation / Answer
please rate - thanks add a variable to count how many numbers were printed, not checkthe number #include #include using namespace std; int main() { int int number = 2 ; while(numberRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.