Skip to main content

Posts

Showing posts with the label GOTO and Label in C

Goto and labels in C Languages

 In the C programming language, the goto statement and labels allow you to transfer control to a specific point in the code. However, the use of goto is generally discouraged due to its potential to make code harder to read and maintain. Let's explore the syntax and usage of goto and labels in C: 1. goto Statement:    The goto statement allows you to transfer control to a labeled statement within the same function. It has the following syntax:    ```c    goto label;    ```    The label is defined as a statement followed by a colon (:). When the goto statement is encountered, the program jumps to the labeled statement, executing the code from that point onwards.    Example:    ```c    int i = 0;    loop:    if (i < 5) {        printf("%d ", i);        i++;        goto loop;    } ...