goto statement in C programming

Written by



goto Keyword

  goto example;
  example: statements;

Here, example can be any text except the <reserved words used in C language and example can be set anywhere i.e. above or below goto statement.

Example :

#include &ltstdio.h>
int main()

for(i=1; i<5; i++) { printf("Value:%d/n",i)

return 0; }

Output :

Value: 1 
Value: 2
Value: 3 
Value: 4

Note: For best practices, avoid using goto keyword as it makes the code unreadable and hard to debug. You can use if, for, switch and while for writing the same program .

goto statement in C programming