Converting int to string

Report a typo

Homer wants to create a small Go program that takes as input an int type number within the num variable, converts it to a string , and prints the converted type and its value to the console.

Since Homer is very lazy, he skipped most of the theory of the topic and didn't remember any of the functions from the strconv package. Below is the code he has written so far:

package main

import (
    "fmt"
    "strconv"
)

func main() {
    var num int
    fmt.Scanln(&num)

    // What is the correct function to convert int types to strings?
    val := ?

    fmt.Printf("%T %v", val, val)
}

Please help Homer finish his program by selecting the correct function to convert the num variable of the int type to a string.

Select one option from the list
___

Create a free account to access the full topic