# Looping Failed "Second Problem"

This is a discussion on Looping Failed "Second Problem" within the C Programming forums, part of the General Programming Boards category; my looping code failed, it reads unlimited number readin, whats wrong with it i didnt figure it out, here's my ...

1. ## Looping Failed "Second Problem"

my looping code failed,
whats wrong with it i didnt figure it out,
here's my problem
Code:
```int main()
{
int x;
int y;
int n;
int m=0;
printf("First Number =");scanf("%d",&x);
printf("Divide Number =");scanf("%d",&y);
printf("Loop Number =");scanf("%d",&n);
while(m<n)   {
x+=y;
printf("%d,",x);
}
}```
Thats for while loop,
here is with do while loop,
Code:
```int main()
{
int x;
int y;
int n;
int m=1;
printf("First Number =");scanf("%d",&x);
printf("Divide Number =");scanf("%d",&y);
printf("Loop Number =");scanf("%d",&n);
do{
x=x+y;
printf("%d,",x);
} while(m<n);
}```
okay, sorry if my code is "unreadable" like other guy said yesterday to me. This the best i can do to explain my problem.
Any ideas?

2. If you can't be bothered to indent properly, have a program do it for you until you can.

Basically all your loops have the same problem. m < n is true forever, because neither variable changes.

3. you need to increase the value of m in the while loop so that it reach n; to end the loop. Using m+=1 at the end of the while loop would help.

4. Code:
```would,   youreaD           a bookwhere;  all rules of-puNctuation-were?simply    ignOred

a

Any good IDE can do the formatting for you. Even if you have a terrible IDE, that's no excuse. I started coding C around 1990, and even without tools to format code, people back then managed to make legible code by manual use of the tab key.

Very simple - every time you enter a new set of braces, you increase by one tab. When you leave that block, you decrease by one tab.

Code:
```int main()
{
int x;
int y;
int n;
int m=0;
printf("First Number =");
scanf("%d",&x);
printf("Divide Number =");
scanf("%d",&y);
printf("Loop Number =");
scanf("%d",&n);
while(m<n)
{
x+=y;
printf("%d,",x);
}
}```

5. Originally Posted by whiteflags
Basically all your loops have the same problem. m < n is true forever, because neither variable changes.
lol i forget for adding an increment on behind,
thanks for whiteflags
this problem solved anyway

still i cant figure it out,
why my code is "unreadable" thing,

by the way this problem solved anyway

6. Originally Posted by loserone+_+
still i cant figure it out,
why my code is "unreadable" thing,