Go Program to print table of any number


In this program, you will learn how to print a table of any number in Go.


for i := 1; i <= 10; i++ { 
    //statement
}

Example: How to print a table of any number in Go

package main
import "fmt"

func main() {

	var num int
	fmt.Print("Enter a number:")
	fmt.Scan(&num)

	fmt.Println()

	for i := 1; i <= 10; i++ {
		fmt.Println(i * num)
	}
}

Output:

Enter a number:5                                                                                                                       
                                                                                                                                       
5                                                                                                                                      
10                                                                                                                                     
15                                                                                                                                     
20                                                                                                                                     
25                                                                                                                                     
30                                                                                                                                     
35                                                                                                                                     
40                                                                                                                                     
45                                                                                                                                     
50