YouTip LogoYouTip

C Goto Statement

C goto Statement

C goto Statement

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 - ">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 - ">C Standard Library - <a href="#" title="C Standard Library - ">C Standard Library - <a href="#" title="C Standard Library -

C Decision Making

C Functions

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

C Loops C Loops

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.

C goto Statement Flow

Flowchart

C goto Statement

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

C Loops C Loops

C Decision Making

C Functions

iFlytek Starlight Coding Plan includes free model call quotas for DeepSeek, GLM, Kimi, MiniMax, a one-stop experience and deployment platform. Configuration Guide Β₯3.9/month Activate Now

Click to Share Notes

Cancel

Write notes...

Image URL

Image Description

Image Size Γ—Restore Size

Share Notes

  • Nickname Nickname (required)
  • Email Email (required)
  • Reference URL Reference URL

Category Navigation

← Python3 Func Number ExpPython3 Func Number Ceil β†’