Ticker

6/recent/ticker-posts

C Language (Goto Statement In C)

GOTO STATEMENT IN C





Goto statement is used to transfer the program control from one statement to another statement by help of label.

GOTO STATEMENT EXAMPMLE
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int age;
char c;
abc:                 //  Define a label
printf(“enter your age:”);
scanf(“%d”,&age);

printf(“do you want to continue (y/n):”);
scanf(“%c”,&c);
if(c==’y’)
{
goto abc;
}
getch();
}


PROGRAM EXPLANATION
The above program first ask to enter your age and then ask to continue.
If you press 'y' then it will throw the program's execution control to the 'abc' label and statements below 'abc' control will execute again. 













Post a Comment

0 Comments