# Looping

Mar 25, 09:46 AM

If you’re a beginner to programming, start at one of the following:

2. Output: Learn to write out messages in Vaklipi

Some things in life are repetitive. You know, you get milk every morning. You go to work every day, but not on Sunday or on holidays.

You can model that with instructions for repeating a set of statements, until something happens.

Take a good look at this.

Let y be 0. Let x be 1. While x is less than 5, set y to y plus x and increment x.

 com.aiaioo.VaklipiVariableFixture program variable run() y is 0. x is 1. While x is less than 5, set y to y plus x and increment x. y 10.0
 fit.Summary

Run test

Did you get what that program does?

You can say the same thing another way:

Let y be 0. Let x be 1. While x is less than 5, increment y by x and increment x.

Is it clearer now?

 com.aiaioo.VaklipiVariableFixture program variable run() Let y be 0. Let x be 1. While x is less than 5, increment y by x and increment x. y 10.0 Let y be 0. Let x be 1. While x is less than or equal to 4, increment y by x and increment x. y 10.0
 fit.Summary

Run test

What you’re doing is adding up all natural numbers less than 5.

The problem in mathematics is called ‘adding a list of integers in arithmetic progression’ but isn’t as complicated as it sounds.

In fact, you don’t even need to use a loop to do it.

You can get the same answer if you just computed x * x / 2 + x / 2.

Try it out for yourself!

 com.aiaioo.VaklipiOutputFixture program run() Let x be 4. What is x * x / 2 plus x / 2 ? 10.0
 fit.Summary

Run test

Now, if you were talking Hindi, you would say something like:

रा का मान ० है. ला का मान १ है. जब तक ला का मान ५ से कम है, तब तक रा में ला जोड़ दो और ला में १ जोड़ दो.

 com.aiaioo.VaklipiVariableFixture program variable run() रा का मान ० है. ला का मान १ है. जब तक ला का मान ५ से कम है, तब तक रा में ला जोड़ दो और ला में १ जोड़ दो. रा 10.0
 fit.Summary

## Learn

You can learn programming with Vaklipi in the following pages:

2. Output: Learn to write out messages in Vaklipi
3. Declarations: Learn to set the value of a variable
4. Operators: Learn to do addition, multiplication, division etc.
5. Conditionals: Learn to take specify the conditions for performing certain steps.
6. Looping: Learn to repeat steps till some condition is satisfied.
8. Functions: Learn to issue an command.
9. Constructors: Learn to create an object of a certain type.
10. Selectors: Learn to refer to a real world object.

## Comment

1. Hi Cohan,

Is it possible to get a working binary for the language other than the web interface?

Looking forward to the rest of the tutorials.

Santhosh Kumar · May 2, 08:58 AM · #

2. Yes, Santhosh, the software can run as a Java library or standalone application.

Cohan · May 2, 09:24 AM · #