Kotlin Program:

- To print X pattern using *

Example:

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 0..rows-1) {
    for(j in 0..rows-1) {
      if(i==j||j==(rows-i-1))print("* ")
      else print("  ")
    }
    println("")
  }
}

Output:

Enter number of rows: 4

*     *
  * * 
  * * 
*     *
Program
pattern

Main Logic :

for(i in 0..rows-1) { //rows : number of rows to print
  for(j in 0..rows-1) {
    if(i==j||j==(rows-i-1))print("* ")
    else print("  ")
  }
  println("")
}

You can print any thing in this pattern, just replace your value with *

Concept

Coming Soon !

Quick
Tutorial

Quote

In order to carry a positive action, we must develop here a positive vision.