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++)

  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 .

Report Error/ Suggestion

Related Posts:

CopyRight © 2020

CopyRight © 2020