Easy C++ Question

Status
Not open for further replies.
To make your code run forever, at least until x equals 50 you could do one of the following:
Code:
do
{
    // insert code here
}while( x != 50 );

Code:
while( x != 50 )
{
    // insert code
}
Code:
for( ; x != 50 ; )
{
    // insert code here
}
Code:
while(1)
{
    // insert code here
    if( x == 50 ) break;
}
Code:
for(;;)
{
    // insert code
    if( x == 50 ) break;
}

Those are just a few ways :p
 
Be very careful with while(true) loops. Many compilers will even issue a warning on that kind of code.
 
hey any value in C conditions other than 0(zero) is treated as true
thats why if u will write
if 1 then
{
}
then the code will get exicuted as value 1 is non zero
so even
if 4+5 then
{
}
will exicute code between
{
}
 
Status
Not open for further replies.
Back
Top Bottom