Advertisement
goto label ;
/* C- The goto statement example */
#include<stdio.h>
int main()
{
int age = 16;
if(age<21)
goto Under21Team;
else
printf("Welcome to Senior Team \n");
Under21Team:
printf("The program has ended");
return 0;
}/* main method ends and so does the program */
The program has ended
Advertisement
/* C- The goto statement */
#include<stdio.h>
int main()
{
int age = 23;
if(age<21)
goto Under21Team;
else
printf("Welcome to Senior Team \n");
Under21Team:
printf("The program has ended");
return 0;
}/* main method ends and so does the program */
Welcome to Senior Team
The program has ended
/* C- goto statement to go out of the loop */
#include<stdio.h>
int main()
{
int counter = 10;
while(counter>=0)
{
counter=counter-1;
printf("Counter : %d \n", counter);
if(counter==5)
goto OutOfLoop;
}
OutOfLoop:
printf("We are out of the loop at the counter 5");
return 0;
} /* main method ends and so does the program */
Counter : 9
Counter : 8
Counter : 7
Counter : 6
Counter : 5
We are out of the loop at the counter 5
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement