Goto Statement in C
Here are the implementation of goto statement in C language:
#include <stdio.h>
int main() {
int i = 0;
loop_start:
if (i < 5) {
printf("%d ", i);
i++;
goto loop_start;
}
return 0;
}
Output
0 1 2 3 4
Goto Statement in Programming
Goto statement is a control flow statement present in certain programming languages like C and C++. It enables programmers to transfer program control to a labeled section of code within the same function or block. Despite its availability, its usage is often discouraged in modern programming practices due to its potential to complicate code structure and reduce readability. In this article, we will discuss about a Goto statement used in programming.
Table of Content
- What is a Goto Statement?
- Syntax of Goto Statement
- Common Use Cases of Goto Statement
- Goto Statement in C
- Goto Statement in C++
- Goto Statement in C#
- Best Practices of Goto Statement
Contact Us