scaramacai
6th June 2018, 10:03
I have this code:
bool state=true;
qDebug() << "Entering while...";
i=0;
while((state==true)||(i<3))
{
state=false;
qDebug() << "Value of counter: "<<i;
i++;
}
qDebug() << "End of while";
but the first condition seem not to work.
The output is:
Entering while...
Value of counter: 0
Value of counter: 1
Value of counter: 2
End of while
If I remove the second condition (i<3), I have
...
while(state==true)
...
//Output
Entering while...
Value of counter: 0
End of while
It seems that only one condition is allowed in while loop.
Is it possible?
bool state=true;
qDebug() << "Entering while...";
i=0;
while((state==true)||(i<3))
{
state=false;
qDebug() << "Value of counter: "<<i;
i++;
}
qDebug() << "End of while";
but the first condition seem not to work.
The output is:
Entering while...
Value of counter: 0
Value of counter: 1
Value of counter: 2
End of while
If I remove the second condition (i<3), I have
...
while(state==true)
...
//Output
Entering while...
Value of counter: 0
End of while
It seems that only one condition is allowed in while loop.
Is it possible?