C++ Programming & Tutorials for Beginners

Jumping Statements | C++ Programming

/*The easiest way to represent break statement*/
#include<iostream>
#include<conio.h>

using namespace std;

int main()
{
cout<<"break Statement\n";
int i;
i = 1;
while(i<=10)
{
if(i==6)
{
break;
}
cout<<"\nI="<<i;
i++;
}
getch();
}














/*The easiest way to represent continue statement*/
#include<iostream>
#include<conio.h>

using namespace std;

int main()
{
cout<<"continue Statement\n";
int i;
for(i=1;i<=10;i++)
{
if(i==6)
{
continue;
}
cout<<"\nI="<<i;
}
getch();
}















/*The easiest way to represent goto statement*/
#include<iostream>
#include<conio.h>

using namespace std;

int main()
{
    cout<<"goto Statement\n";
    int i;
        
    Bintu: //here Bintu is the name of goto Label
    cout<<"Enter any Number: ";        
    cin>>i;
    
    if(i==5)
    {
        goto Bintu;
    }
    cout<<"\n goto Label: "<<i;
    getch();
}




Previous
Next Post »