Kotlin Program to print table of any number
In this program, You will learn how to print a table of any number in Kotlin.
5 10 15 20 25 30 35 40 45 50
Example: How to print a table of any number in Kotlin.
import java.util.Scanner
fun main(args: Array<String>) {
var num: Int
var t: Int
var sc = Scanner(System.`in`)
print("Enter a number:")
num = sc.nextInt()
for(i in 1..10){
t = num * i
println("$num * $i :$t")
}
}
Output:
Enter a number:5
5 * 1 :5
5 * 2 :10
5 * 3 :15
5 * 4 :20
5 * 5 :25
5 * 6 :30
5 * 7 :35
5 * 8 :40
5 * 9 :45
5 * 10 :50