![]() |
convert for loop into while and do..while
Code:
#include<stdio.h>1 22 333 4444 55555 this is the "for" method, how do i convert it into while and do..while format? i just still noob in programming , any expert help me out pls? thx |
Re: convert for loop into while and do..while
for ( a ; b ; c ) d;
Is approximately a; while ( b ) { d; c; } |
Re: convert for loop into while and do..while
ya, but if got 2 loops? for(i=0;i<=8;i++) the first loop then inside another for (j=0;j<=i;j++)?
|
Re: convert for loop into while and do..while
So two for loops become two while loops - what's the problem?
|
Re: convert for loop into while and do..while
Code:
int i=1,j=1;1 22 333 4444 55555 |
Re: convert for loop into while and do..while
Code:
int i=1,j=1; |
Re: convert for loop into while and do..while
For while loop you should increment the counter as the last statement and then it will be equivalent.
Do while loops are a bit different and cannot be equal to for loop but in your case applying the increment as the last statement of the loop would do. |
Re: convert for loop into while and do..while
i don't really get what u really mean.. how about u post the code for me? then i will know better
|
Re: convert for loop into while and do..while
Refer to my other post
Code:
for(i=1;i<=5;i++) {Code:
i=1; |
Re: convert for loop into while and do..while
kk, thx so much for the help
|
| All times are GMT +5.5. The time now is 14:55. |