Documentations - SRON
  • SRON's Official Documentation
  • Installation
  • Syntax of SRON
  • Executing a SRON code
  • Keywords in SRON
  • Comments in SRON
  • Datatypes in SRON
  • Variables in SRON
  • Memory Ownership Model
  • Operators in SRON
  • Math block
  • if elif else in SRON
  • Loops in SRON
    • For Loop
    • While Loop
    • Foreach Loop
  • Break & Continue
  • Functions in SRON
    • Print functions
    • User Input Functions
    • Type Conversion functions
    • Type Checking functions
    • Math functions
    • Char Functions
    • String Functions
    • List Functions
    • Miscellaneous functions
  • Return in SRON
  • Command Line Arguments
  • Free
  • Rotate
  • Console
  • Sample codes
  • Coding Convention
  • Frequently Asked Questions
  • Credits
  • Contact
  • Donate
Powered by GitBook
On this page
  1. Loops in SRON

For Loop

'for' is a looping attribute which is used to perform a set of instructions multiple times in a given range.

SRON provides 'for' attribute to work on for loop. To provide a start and end point to the loop, 'range' attribue is used.

Syntax of 'range':

range : (variable = start_point, end_point, steps)

Examples:

Correct Syntax:
    range : (Int i = 0, 10)
or
    range : (i = 0 , 10)

------------ 

Wrong Syntax:
    range : Int i = 0, 10
or
    range : (50)

By default, the steps are set as 1, so you don't need to specify it explicitly.

Sample Code to print 0 to 5 numbers.

{
    name : MAIN
    for : {
        range : (Int i= 0, 6)
        0 : println(i)
    }
}

OUTPUT :

0 1 2 3 4 5


Sample Code to print even number between 0 and 15.

{
    name : MAIN
    for : {
        range : (Int i= 2, 15, 2)
        0 : print(i, ' ')
    }
}

OUTPUT :

2 4 6 8 10 12 14


PreviousLoops in SRONNextWhile Loop

Last updated 6 months ago