C goto Statement
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
C Tutorial
C Language TutorialC IntroductionC Environment SetupC VScodeC Program StructureC Basic SyntaxC Data TypesC VariablesC ConstantsC Storage ClassesC OperatorsC Decision MakingC LoopsC FunctionsC Scope RulesC ArraysC enum(Enumeration)C PointersC Function Pointers and Callback FunctionsC StringsC StructuresC UnionsC Bit FieldsC typedefC Input & OutputC File I/OC PreprocessorsC Header FilesC Type CastingC Error HandlingC RecursionC Variable ArgumentsC Memory ManagementC Undefined BehaviorC Command Line ArgumentsC Safe FunctionsC Sorting AlgorithmsC Project StructureC Language ExamplesC Language Classic 100 ExamplesC Quiz
C Standard Library
C Standard Library - Reference Manual<a href="#" title="C Standard Library - ">C Standard Library - <a href="#" title="C Standard Library - ">C Standard Library - <a href="#" title="C Standard Library - ">C Standard Library - <a href="#" title="C Standard Library - ">C Standard Library - <a href="#" title="C Standard Library - ">C Standard Library - <a href="#" title="C Standard Library - ">C Standard Library - <a href="#" title="C Standard Library -
In-Depth Exploration
Software
Programming
Scripting
Web Service
Programming Languages
Scripting Languages
Web Design and Development
Development Tools
Web Services
Computer Science
C goto Statement
The goto statement in C allows unconditional transfer of control to a labeled statement within the same function.
Note: The use of the goto statement is not recommended in any programming language because it makes the control flow of a program difficult to trace, making the program hard to understand and modify. Any program that uses the goto statement can be rewritten without using it.
Syntax
The syntax of a goto statement in C is as follows:
goto label;
...
label: statement;
Here, label can be any plain text except a C keyword. It can be placed either before or after the goto statement in a C program.
Flowchart
Example
Example
#include<stdio.h>
int main () {
/* local variable definition */
int a = 10;
/* do loop execution */
LOOP:do {
if( a == 15) {
/* skip the iteration */
a = a + 1;
goto LOOP;
}
printf("value of a: %dn", a);
a++;
} while( a < 20 );
return 0;
}
When the above code is compiled and executed, it produces the following result:
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19
Click to Share Notes
Write notes...
Image URL
Image Description
Image Size ΓRestore Size
Share Notes
- Nickname Nickname (required)
- Email Email (required)
- Reference URL Reference URL
YouTip