# Golang program to print the Octal value of numbers from 1 to 100 using the goto statement

Here, we are going to learn how to print the Octal value of numbers from 1 to 100 using the goto statement in Golang (Go Language)?
Submitted by Nidhi, on February 21, 2021 [Last updated : March 03, 2023]

## Golang goto Statement Example – Print the Octal value of numbers from 1 to 100

Problem Solution:

In this program, we will print the octal number corresponding to the decimal number from 1 to 100 on the console screen.

Program/Source Code:

The source code to print the Octal value of numbers from 1 to 100 using goto statement is given below. The given program is compiled and executed successfully.

## Golang code to print the Octal value of numbers from 1 to 100 using the goto statement

```// Golang program to print the Octal value of numbers
// from 1 to 100 using goto statement

package main

import "fmt"

func main() {

var val int = 1

XYZ:
fmt.Printf("%o ", val)
val = val + 1

if val <= 100 {
goto XYZ
}
}
```

Output:

```1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 20 21 22 23 24 25 26 27 30
31 32 33 34 35 36 37 40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 5
7 60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77 100 101 102 103 104
105 106 107 110 111 112 113 114 115 116 117 120 121 122 123 12
4 125 126 127 130 131 132 133 134 135 136 137 140 141 142 143 144
```

Explanation:

In the above program, we declare the package main. The main package is used to tell the Go language compiler that the package must be compiled and produced the executable file. Here, we imported the fmt package that includes the files of package fmt then we can use a function related to the fmt package.

In the main() function, we created a variable val with an initial value of 1 and created a label XYZ.

After that increase the value of variable val by 1 till it becomes 100 and print corresponding octal values using the "%o" format specifier on the console screen,

```if (val<=100){
goto XYZ
}
```

The above code will transfer program control to the XYZ label if the value of variable val is less than equal to 100.