while loops
How do I trun these for loops in to while loops?
for(i=2;i<=n;i++)
{
k=0;
for(j=1;j<=i;j++)
if(i%j==0) k++;
if(k==2)
cout << ", " << i;
}
Generic for loop:
1 2 3 4
|
for (int i = 0; i < max; i++)
{
//do some stuff
}
|
Generic while loop equivalent:
1 2 3 4 5 6
|
int i = 0;
while(i < max)
{
//do some stuff
i++;
}
|
Topic archived. No new replies allowed.