Solution:NIIT/GNIIT Sonugiri0032@gmail.com

Wednesday, January 06, 2016

Goto Statement in C++

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:

0 comments:

GNIITSOLUTION GNIIT SOLUTION. Powered by Blogger.

Translate

Blog Archive

Unordered List