#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.
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.