goto

  Example of goto Statement.

#include<conio.h>
#include<iostream.h>
#include<stdlib.h>
void main()
{
int age;
clrscr();
cout<<"Enter your age"<<endl;
cin>>age;
if(age>=18)
goto abc;
else
{
cout<<"you can't do voting"<<endl;
cout<<"you should wait till the age of 18"<<endl;
getch();
exit(1);
}
abc:
cout<<"you are in democracry"<<endl;

getch();
}

Result of goto :-

goto statement in c++

Result :-

goto example in c++




Follow Us

Contact Us

tutorialworldin@yahoo.com

Back to Top