What's new

Closed For loop to while loop

Status
Not open for further replies.
pag hiwa-hiwalayin nyo lang po yung initialization, condition, at pag increment
Code:
int x = 0, n = 10;
while (x < n) {
    //...
    int y = 0;
    while (y < x){
        //...
        y++;
    }
    x++;
}
 
Payo lang sa mga baguhan sa C++, mas magandang gamitin ang pre-increment(++y) kesa sa post-increment(y++) kung nasa single statement lang ito o hindi kasali sa any equation/evalution.

Code:
int x = 0, n = 10;
while (x < n) {
    //...
    int y = 0;
    while (y < x){
        //...
        ++y;  // pre-increment here
    }
    ++x;  // pre-increment here
}
 
Status
Not open for further replies.

Similar threads

Back
Top