Categories
b. Variables and Keywords

goto

The goto statement is used to transfer control of the program to the specified label. For example:

for(i=1; i<5; ++i)
{
    if (i==10)
    goto error;
}
printf("i is not 10");
error:
    printf("Error, count cannot be 10.");

Output

Error, count cannot be 10.

Leave a Reply

Your email address will not be published. Required fields are marked *