Originally Posted by
cloudstrife910
here I'll try and rewrite it
Code:
#include<iostream>
using namespace std;
int main()
{int num=3, checknum, remainder, answer=1;
do{checknum=2;
while(checknum<num-1)
{remainder=num%checknum;
if(remainder==0)
{answer=0;
continue;}
else
answer=1;
checknum++;
}
if(answer=1)
{cout<<""<<num;}
num++;
}while(num<101);
return 0;
}
now will you help? pleassse?
Meh, here's how I would do it:
Code:
#include<iostream>
using namespace std;
int main() {
int num=3, checknum, remainder, answer=1;
do {
checknum=2;
while(checknum<num-1) ;
{
remainder=num%checknum;
if(remainder==0) {
answer=0;
continue;
} else
answer=1;
checknum++;
}
if(answer=1) {
cout<<""<<num;
}
num++;
} while(num<101);
return 0;
}
Now, while I was indenting, I realized that your code is a total mess. I am quite sure that it does not do anything you want at all. Can you try and explain what you wanted to do with each line or set of lines in it?
Hint: You have a while loop that does nothing, since it has an extra comma in front of it. It's highlighted.