Nested While Loops Are Confusing

This is just a random test program I made, to understand more about nested while loops but...
I keep getting an infinite loop.
For Example if I input 5 I get an infinite loop and I don't understand why?
If I input 5 wouldn't that mean starcounter will equal 5
and 5 subtract rowcounter ( which should be 1) = 4 and therefore that condition would be false and the loop will exit?
The codes below:


#include<iostream>
using namespace std;
int main(){
int sizecounter=0,size,rowcounter=0,starcounter=0,spacecounter=0;


cout<<"Please enter the size of your diamond"<<endl;
while(sizecounter<1){
cin>>size;
sizecounter++;}


while(size==size){
starcounter++;
spacecounter++;
rowcounter++;
while (starcounter<size){
starcounter++;}
while ((starcounter-rowcounter)< spacecounter){
spacecounter++;
cout<<" ";}
}

return 0;
}
It doesn't matter what input or calculation. This size==size will always be true and hence this while(size==size) will loop forever.
Topic archived. No new replies allowed.