CodersEditor Tutorials

CodersEditor Tutorials

  • Online IDE
  • Q&A
  • C Programming
  • Java
  • GraphQL.NET
  • System Software

›Loop

C Programming

    Introduction

    • Overview
    • Installation & Setup
    • C Program Structure
    • Keywords & Identifiers
    • Data Types
    • Variables & Constants
    • Scope Rules
    • Storage Class
    • Standard Input and Output
    • Operators

    Control Flow/Decision Making

    • Overview
    • if Statement
    • if else Statement
    • Nested If statement
    • Switch Statement
    • Nested Switch Statement
    • Conditional Operators

    Loop

    • Loops Overview
    • While loop
    • For Loop
    • Do while
    • Nested Loops
    • Break
    • Continue Statement
    • Goto statement

    Arrays

    • Arrays
    • Multi Dimensional Arrays
    • Arrays & Functions

    Pointers

    • Pointers Basics
    • Pointers and Arrays
    • Pointers and Functions
    • Memory allocation

    Strings

    • String Basics
    • String Functions

    C Programming Examples

    • Basic Example 1

Goto statement in C

This article is about the Goto statement in C programming. Also, when and how to use it in your C programs.

Goto statement in C

The goto statement is a transfer control statement that provides an unconditional jump from the 'goto' to a specified labeled statement in the same function.

When a goto statement is met, the control of the program is transferred to the label and starts executing the code given in the label. The label is an identifier

NOTE – The main disadvantage of the goto statement is that it makes it difficult to trace the control flow of a program and makes the program hard to understand and modify.

Syntax

goto label;
... .. ...
... .. ...
label: 
statement;

Example

#include <stdio.h>  
int main()   
{  
    int a,i=1;   
    printf("Enter the value:");   
    scanf("%d",&a);  
    data:   
    printf("%d x %d = %d\n",a,i,a*i);  
    i++;  
    if(i<=5)  
    goto data;    
}    

Output

Enter the value:5
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
← Continue StatementArrays →
  • Goto statement in C
  • Syntax
  • Example
  • Output
CodersEditor Tutorials
CoderdEditor Developer Tools
CodersEditor Online EditorGit Flavoured Markup EditorFree Online JSON FormatterFind My IP Address Details
Tutorials
C ProgrammingJava
Copyright © 2021 CodersEditor.com