continue语句,
跳过循环体中continue语句之后的任何语句,返回控制到while循环的开始。以下例子说明continue语句的用法:
class loops
{
int num;
char reply;
public:
void square()
{
reply='y';
while(reply!='n')
{
cout<<"enter a number less than 100"<<endl;
cin>>num;
if(num>100)
{
cout<<"The number is greater than 100"<<endl;
continue;
}
cout<<"The square of the number is "<<num*num<<endl;
cout<<"Do you want to enter another (y/n)";
cin>>reply;
}
}
};
int main()
{
loops a;
a.square();
return o;
}