- To print full blank square pattern using *
User Input: 3
Output:
* * * * * * * *
fun main(args: Array<String>) {
print("Enter number of rows : ")
val userInput = readLine()!!
var rows:Int =userInput.toInt()
for(i in 1..rows) {
for(j in 1..rows) {
if(i==1||i==rows||j==1||j==rows)print("* ")
else print(" ")
}
println("")
}
}
Enter number of rows: 6 * * * * * * * * * * * * * * * * * * * *Program
Main Logic :
for(i in 1..rows) {
for(j in 1..rows) {
if(i==1||i==rows||j==1||j==rows)print("* ")
else print(" ")
}
println("")
}
You can print any thing in this pattern, just replace your value with *
Coming Soon !
QuickIn order to succeed you must fail, so that you know what not to do the next time.