C Programming goto Statement

C Programming goto Statement

Go to statement in c programming; Through this tutorial, you will learn how to use go to statement in c program.

C Programming goto Statement

When a goto statement is encountered in a C program, the control jumps directly to the label mentioned in the goto statement

Syntax of goto Statement in c programming

See the following syntax of go to statement in c; as shown below:

goto label;
... .. ...
... .. ...

The label is an identifier. When the goto statement is encountered, the control of the program jumps to label: and starts executing the code.

Example 1 – Goto Statement in C program

See the following example for goto statement in c; as shown below:

#include <stdio.h>
int main()
   int sum=0;
   for(int i = 0; i<=10; i++){
	sum = sum+i;
	   goto addition;

   printf("%d", sum);

   return 0;



Explanation of above c program:

  • Iterate for loop and specify condition inside the loop is i == 5
  • Then jumping to this label using goto
  • This is reason the sum is displaying the sum of numbers till 5 even though the loop is set to run from 0 to 10


My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *