The goto Keyword in C Language



 The goto statement is used for unconditional jump from one part of the program to another part of the program. It is always suggested not to use goto statement as this reduces the readability of the program. Using goto statement is considered as poor programming approach.
The goto statement consists of two parts: label and goto keyword.

Example:

/*use of goto statement*/
#include<stdio.h>
#include<conio.h>
void main(){
int a;
goto label;
a = 10;
printf(“%d”, a);
label:
a = 20;
printf(“%d”, a);
}
Output:
20

When goto label is encountered, control goes to the statement next to the label. Here, label is not the keyword. We can use any name for the label. It’s user defined.


Responses

0 Respones to "The goto Keyword in C Language"

Post a Comment

 

Total Pageviews

Return to top of page Copyright © 2011 | Kuppam Engineering College Converted into Blogger Template by Mohan Murthy