Kotlin Program:

- To print half triangle pattern using alphabet

Example:

User Input: 3

Output:

A
B B
C C C
fun main(args: Array<String>) {
  print("Enter number of rows : ") 
  val userInput = readLine()!!
  var rows:Int =userInput.toInt()
  var c:Char

  c='A'
  for(i in 1..rows) {
    for(j in 1..i) {
      print(c+" ")
    }
    c++
    println("")
  }
}

Output:

  Enter number of rows : 4
  A
  B B
  C C C
  D D D D
Program
pattern

Main logic :

c='A'
for(i in 1..rows) {  //rows : number of rows to print
  for(j in 1..i) {
    print(c +" ")
  }
  c++
  println("")
}

You can print the same pattern in small alphabets, just set c='a'

Concept

Coming Soon !

Quick
Tutorial

Quote

I believe things cannot make themselves impossible.