goto Statement in C Language
×


goto Statement in C Language

98

 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>
int main()
{
	int A = 1;
	start:
	printf(" A = %d\n", A);
	A++;
	{
	if(A<=5)
	goto start;
	return 0;
	}
}
Output:

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.



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments