#include<iostream>
using namespace std;
int main()
{
int x,y,n=0,ch='y';
while(ch=='y')//problem loop
{
gno:
x=rand()%9999+1000;
y=x;
n=0;
while(y>0)
{
y=y/10;
n++;
if(n>3&&n<3)
goto gno;
}
cout<<x<<endl;
cin>>ch;
}
return 0;
}
Whenever I run the above code, it displays one random number as it should. But after that even when I enter the value of ch as "y" (without the quotes, of course!) the while loop marked as "problem loop" just doesn't continue. Ya, I get it that it's some kind of a runtime error but can anyone please specify what is causing this problem, and by making what exact changes to the code will let me run it successfully?