Loops in SRON

Loops are the most vital component of programming which is used to perform a set of tasks multiple times.

For example, if you want to print your name more than 10 times, then rather than writing your name 10 times, you can put it inside a loop given in SRON to perform this task.

SRON provides 3 types of Loop:

  • For

  • While

  • Foreach


{
    @ for loop demonstration

    name : MAIN
    for : {
        range : (Int i = 1, 11)
        println("Hello, SRON!")
    }
}
{
    @ while loop demonstration

    name : Main
    while : {
        condition : (true)
        println("Boooom!!")
    }
}
{
    @ foreach loop demonstration

    name : Main
    foreach : {
        on : (Any i , [1,2,3,4,5])
        println(i)
    }
}

Last updated