Saturday, 15 June 2013

week 14 day 3

The condition tested in a while loop can only be a valid C++ expression. As long as that condition remains true, the while loop continues. You can create a loop that never ends bt using the value true for the condition to be tested.

#include<iostream>
int main()
int counter = 0;
while(true)
{
counter ++;
if(counter>0)
break;
}
std::cout<<"Counter: "<<counter<<std::endl;
return 0;
}

No comments:

Post a Comment