Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 1022 Bytes

README.md

File metadata and controls

34 lines (25 loc) · 1022 Bytes

Loops

A loop is used to excute a block of code, i.e, a set of instructions that perform a set of tasks, based on a condition over iterations.

There exists two/three kinds of loops:

  1. for loops
  2. while loops
  3. do-while loops

Eg:

val names = ["Kavya", "Manas", "Likitha"]
for(name in names){
    println("Good morning, $name. Have a great day.")
}

Learning Objectives

  • What are loops?
  • Syntax to construct a loop
  • What are the types of loops and how to choose them
  • Syntax of a for loop
  • Syntax of a while loop
  • Syntax of a do-while loop

Programs

  • Loops.kt - A simple program in Kotlin to understand loops, their syntax, and power
  • ForLoops.kt - A simple program to understand for loops, their syntax, and power.
  • Display10Nums.kt - A simple program to display the half of the first 10 whole numbers.
  • MultiplicationTable.kt - A simple program to generate the multiplication table for a given number for 10 rows.