Syntax
a > b >
goto label;
label;
………….. ………….
…………. ………….
…………. ………….
Label;
goto label;
Statement;
/*A program to find the sum of n natural numbers using goto statement */
#include < stdio.h > //include stdio.h header file to your program
main ( ) //start of main
{
int n, sum = 0, I = 0, // variable declaration
printf (“Enter a number”); // message to the user
scanf (“%d”, &n); //Read and store the number
Loop: I ++; //Label of goto statement
Sum + = I; //the sum value in stored and I is added to sum
If (i < n) goto Loop;
Printf (“\n sum of %d natural numbers = %d”, n, sum);
}