Problems inputting a variable because of the way compiler reads code
I'm new here. Here is a piece of code in C++
int main()
{
cout<<"?";
int a;
cout<<"?";
cout<<"Enter no: ";
cin>>a;
cout<<"?";
for(int i=0;i<5;i++)
while(i>0)
i=i/2;
cout<<"?";
}
In this code, the nested for-while loop is basically an infinite loop. The code should ideally print 2 question marks... ask for input... input... print 1 question mark... and enter the infinite loop. But, nothing happens after asking for input. That may be because the compiler reads the code in some different order that I'm not aware of... Is that what is happening. What is happening?
I'm new here. Here is a piece of code in C++
int main()
{
cout<<"?";
int a;
cout<<"?";
cout<<"Enter no: ";
cin>>a;
cout<<"?";
for(int i=0;i<5;i++)
while(i>0)
i=i/2;
cout<<"?";
}
In this code, the nested for-while loop is basically an infinite loop. The code should ideally print 2 question marks... ask for input... input... print 1 question mark... and enter the infinite loop. But, nothing happens after asking for input. That may be because the compiler reads the code in some different order that I'm not aware of... Is that what is happening. What is happening?