goto Statement in C Language
0 263
goto statement in C is a tool that allows you to jump directly to a specific part of your code, bypassing the usual order of execution.
It's like a shortcut that helps you skip forward or go back to a different section of your program.
It is often considered a bad practice because it can make code hard to understand and debug.
goto statement in C Explanation
Syntax of goto statement in C Language
goto label;label is a predefined identifier.
Example:
// Program for goto statement in C #include<stdio.h>Output:int main() { int A = 1; start: printf(" A = %d\n", A); A++; { if(A<=5) goto start; return 0; } }
A = 1 A = 2 A = 3 A = 4 A = 5
In this code, we have used goto to jump back to the start, printing 1 to 5.
Share:
Comments
Waiting for your comments