How can I print `%` in fmt.Printf

I’ve the below code:

package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello, playground")

	h := 5
	r := 3
	fmt.Printf("\n%v / %v = %v ", h, r, h/r)
	fmt.Printf("\n%v % %v = %v ", h, r, h%r)
}

But the output is:

Hello, playground

5 / 3 = 1 
5 %v = 3 %!(EXTRA int=2)

The first line is fine, but the second one is not, as it is not escaping the % how can I fix it?

1 Like

From the package fmt documentation:

%% a literal percent sign; consumes no value

1 Like

Thanks a lot.

how to fix it out just modify line
new=>fmt.Printf("\n%v %% %v = %v “, h, r, h%r)
instead of
old=>fmt.Printf(”\n%v % %v = %v ", h, r, h%r)