GO Program to convert character to the uppercase letter

How to convert character to the uppercase letter

Here we are explaining how to convert characters to the uppercase letters in the Go program. We can use the built-in function fmt.println() to print anything and fmt.scanln() for reading the values. This function is defined under the fmt package and it helps to write standard output. In order to use these functions, we need to import the “fmt” package.

func IsLetter(r rune) bool 

IsLetter reports whether the given rune is a letter (category L)


How to convert character to the uppercase letter in GO Program

We are using fmt.println() function for printing the string to the output screen. Here we are showing how to convert characters to the uppercase letters in the Go language. Here variable chr is used to hold the read character. For reading the character create the reader using NewReader. Check the character read is an alphabet or not by using unicode.IsLetter(chr). If it is an alphabet convert that character into the uppercase letter using unicode.ToUpper(chr). Finally print the results. Given below are the steps which are used in the Go program. 


STEP 1: Import the package fmt, bufio, os, unicode

STEP 2: Start function main()

STEP 3: Create a reader using NewReader as reader := bufio.NewReader(os.Stdin)

STEP 4: Read the character into variable chr as chr, _, _ := reader.ReadRune()

STEP 5: Check the character is an alphabet or not by using unicode.IsLetter(chr) in if condition

STEP 6: If true convert the character using unicode.ToUpper(chr)

STEP 7: print the result using fmt.println()

GO Source Code

                                          package main

import (

func main() {

    reader := bufio.NewReader(os.Stdin)
     fmt.Print("Enter the character to be cThe Uppercase character of %c = %c\n", chr, up)
    } else {
        fmt.Printf("Please enter a valid alphabet\n")



Enter the character to be c
The Uppercase character of b = B
 Enter the character to be c
Please enter a valid alphabet