While Loop Problem.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "stdafx.h"


#include <iostream>
int main(){
	int a;
	int aUnits;
	int aTenths;
	int aHundredths;



	while (aUnits = 1, aUnits <= 9){

		while (aTenths = 10, aTenths <= 90){

			while (aHundredths = 100, aHundredths <= 900){


				aUnits++;
				aTenths++;
				aHundredths++;
				while (aUnits + aTenths + aHundredths < 1000){



					a = aHundredths + aTenths + aUnits;


					std::cout << " " << std::endl;
					std::cout << a;
				}


			}
		}
	}
}


When I put in the last while statement it just keeps on printing 114 forever, if I don't write that last while statement, it keeps on looping till infinity of numbers, can't figure out why.
Last edited on
Not completely sure, but shouldnt last while loop be something like this ?
while (a < 1000)
Last edited on
I tried that before this, same result.
You never change anything in the body of the inner while loop, so the test is always the same and the value of a is always the same, therefore an infinite loop.
Topic archived. No new replies allowed.