Operators

Mar 25, 08:51 AM


Now you’ve come to the fun part of programming – operators!

Operators are things like:

Operator Example
Addition 3 + 2
Subtraction 3 – 2
Multiplication 3 * 2
Division 6 / 3
Exponentiation 4 ^ 2

Now you remember when you were a kid, your mom or dad might have asked you:

What is 4 times 3?

Let’s see what Vaklipi would say if it was asked such a question.


com.aiaioo.VaklipiOutputFixture
program run()
What is 4 times 3? 12.0
fit.Summary

Run test

It knows its math, yeah? We can ask it other things like:

What is 10 plus 2 divided by 3?

Here below is a set of examples in English:


com.aiaioo.VaklipiOutputFixture
program run()
What is 10 plus 2 divided by 3? 4.0
What is 10 into 2 divided by 4? 5.0
What is 10 plus 2 plus 4? 16.0
What is 10 plus 2 minus 4? 8.0
fit.Summary

Run test

Oh! It looks like there was a mistake on the first line!

10 plus 2 divided by 3 is treated as 10 plus (2 divided by 3), and not as (10 plus 2) divvied by 3.

Why so? Well, there is a convention in math called BODMAS.

This convention puts division before addition. That’s all.

Learn more about BODMAS here: http://www.mathsisfun.com/operation-order-bodmas.html

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

३ गुणा २ (3 times 2)


com.aiaioo.VaklipiOutputFixture
program run()
३ गुणा २ छापो. 6.0
fit.Summary

Run test


Learn


You can learn programming with Vaklipi in the following pages:

  1. Introduction: Learn about Vaklipi
  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.
  7. Jumping: Learn to jump to some point in the code.
  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.

Cohan Sujay Carlos

Vaklipi,

---

Comment

Commenting is closed for this article.

---