What are the default values of an int, float variables in Go language?

In this tutorial, we are going to learn about the int, float variables, and the default values of an int, float variables in Go language.
Submitted by IncludeHelp, on October 02, 2021

The int, floats (float32 and float64) are the built-in data type in Go language. Their default values are 0.

Example:

// Golang program to demonstrate the default
// values of an int and floats variable

package main

import (
	"fmt"
)

func main() {
	var x int
	var y float32
	var z float64

	fmt.Println("Default value of an int is", x)
	fmt.Println("Default value of a float32 is", y)
	fmt.Println("Default value of a float64 is", z)
}

Output:

Default value of an int is 0
Default value of a float32 is 0
Default value of a float64 is 0

Golang FAQ »




Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.