Thursday 5 February 2015

Goto Statement in C++

Structure of the Problem Requirements 

Goto statement provide a jump without any condition to the goto specific label in a function. Through goto stalemate we also make our program infinite . But goto statement leave badly impact on the flow of program and programmer and developers recommend to avoid it.

Source Code

#include<iostream> 
using namespace std;
int main()
{
string name ;
int ID ;
string job;
char choice;
 welcome:cout<<endl;
cout<<" Enter Your Name : ";
cin>>name;
cout<<" Enter Your ID : ";
cin>>ID;
cout<<" Enter Your Job Title : ";
cin>>job;
cout<<" Do You want to Stay with us? Y/N : ";
cin>> choice;
if (choice == 'Y')
{
goto welcome;
}
if (choice == 'N')
{
return 0;
}
}

Output of the Program

Goto Statement in C++

Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment