Menu Close

Go – Program to print ASCII value of a character in go

Here, we will write a Program to print ASCII value of a character in go. ASCII aka American Standard Code for Information Interchange is used to represent characters into numeric value.

ASCII characters value lies between 0 to 127. Character represents in go as rune data type.

Example:

Characters     ASCII
----------      -----

A               65
0               48
a               97

Code:

package main

import (

 "fmt"

)

func main() {

  c := 'A' // As a rune

  s := 'a'

  d := '0'

  fmt.Printf("ASCII value %d of character %c \n", c, c)

  fmt.Printf("ASCII value %d of character %c \n", s, s)

  fmt.Printf("ASCII value %d of character %c \n", d, d)
}

Output:

ASCII value 65 of character A

ASCII value 97 of character a

ASCII value 48 of character 0

To learn more about golang. Please follow given below link.

https://techieindoor.com/go-lang/

References:

https://golang.org/doc/
https://golang.org/pkg/

Posted in golang, golang program

Leave a Reply

Your email address will not be published. Required fields are marked *