How to use break statement in for loop in c++

Break statement is use to finish the iteration of loop in a specific point.

Source Code 

#include<iostream>
using namespace std;
int main ()
{
 for (int i =1; i < 9; i++)
 {
  if (i==7)
  break;
  cout<<i<<endl;
 }
}

Output of the Program

C++ Programming

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment