GOTO Statement

Estudies4you

‘goto’ statement
‘goto’ statement is used, when we want to transfer the control to some point in the program unconditionally, which is not in step by step sequence of a program, so a different path for the execution of a program is set up.
It is not preferable to use goto statement.

Example:
Sample program, using ‘goto’ statement
#include<stdio.h>
int main(void)
{
int I,j;
for(i=1;j<=10;j++)
{
for(i=1;i<=10;i++)
{
if(j<10)
goto out;
printf(“\n Murphy’s first law”);
}
printf(“If the price of the PC is a dream”);
}
out         //Label
printf(“Dream about a nightmare”);
return 0;
}
OUTPUT
Dream about a nightmare.

To Top