Print Star ( * ) in Kotlin

Jaspreet Singh
McAppMedia
Published in
Sep 30, 2019

Print star ( * ) in kotlin.

We are going to print

*****
*****
*****
*****
*****

this pattern .

For this Pattern, we need 2 for loop .

First forloop is for Row.

Second forloop is for Column.

fun squarePatternStar(){

var n = 5

for (i in 0 until n) {

for(j in 0 until n){

print("*")
}
println(" ")
}

}

Above Code Print * as we expected.

fun main(){

squarePatternStar()
}

main function is calling squarePatternStar

--

--

Jaspreet Singh
McAppMedia

Working in Android Developemen and Tech Mentor .My Github profile is: https://github.com/jaspreet1990 , Contact me at preetjaspreet90@gmail.com for more info.