Change for, into While loop

How can I change this for loop into a while loop?


 
for(int p=10; p>=0; p-=2)
1
2
3
4
5
6
7
8
9
10
11

int p = 10;

while( p >= 0 )
    {
    p -= 2;

    }


Figured it out!

int p=10;

while(p>=0){

cout<<p<<endl;

p=p-2;
}



1
2
3
4
5
6
int p = 10;//initialize outside while loop
    while (p >=0)
    {
        //do stuff;
        p -= 2;//decrement inside while loop 
    }
Topic archived. No new replies allowed.