Break from while : break « Operators statements « C++ Tutorial






#include<iostream.h>
int main()
{
  int x,y,s;
  cin >> x >> y;
  s=0;
  while(1)
  {
    if(s==0)break;
    s +=x;
  }
  cout<<s<<endl;
}
1
2
2








3.18.break
3.18.1.Break a for loop
3.18.2.Break an infinite loop
3.18.3.Break from while
3.18.4.Demonstrating a Forever Loop