---
title: 2.18 goto Statement
description: "The `goto` statement transfers execution directly to a labeled statement within the same function. The destination is specified using a label followed by a colon. ``` #include int main() { int number = 0; if (number == 0) { goto…"
url: "https://edcret.in/docs/c-programming/control-flow/2-18-goto-statement/"
updated: "2026-09-06"
category: C Programming / Control Flow
---

# 2.18 goto Statement

The `goto` statement transfers execution directly to a labeled statement within the same function. The destination is specified using a label followed by a colon.

```
#include <stdio.h>

int main()
{
    int number = 0;

    if (number == 0)
    {
        goto zero;
    }

    printf("This statement is skipped.\n");

zero:
    printf("Number is zero.\n");

    return 0;
}
```

### Example Output

```
Number is zero.
```

### Explanation

The `goto` statement transfers control to the label named `zero`:

```
goto zero;
```

The destination is defined by:

```
zero:
```

Because execution jumps directly to this label, the following statement is skipped:

```
printf("This statement is skipped.\n");
```

A `goto` statement can only transfer control to a label within the **same function**. Labels themselves are covered separately in the next lesson.
