Conditionals

Mar 25, 09:31 AM


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

  1. Introduction: Learn about Vaklipi
  2. Output: Learn to write out messages in Vaklipi


So far, we haven’t really had to deal with logic, have we?

Logic is about evaluating the truth and falsehood of a statement.

In programming, it is important to do some things based on whether or not certain conditions hold (that is, evaluate to true).

A good example is describing the price of a book. If the price is greater than 200 rupees, you might want to say “expensive” and otherwise you might want to say “not expensive”. In Vaklipi, let’s say the book’s price is referred to by the variable p, you can say the following:

If p is greater than 200, say “expensive” else say “not expensive”.


com.aiaioo.VaklipiOutputFixture
program run()
p is 150. If p is greater than 200, say “expensive” else say “not expensive”. not expensive
fit.Summary

Run test

We can also say things like:

Say “boo” if 10 plus 2 is greater than 3.

Here below is a set of examples in English:


com.aiaioo.VaklipiOutputFixture
program run()
Say “boo” if 10 plus 2 is greater than 3. boo
x = 2. y is 3. If x is less than y, print y else print x. 3.0
x = 2. y is 3. If x is more than y, max is x else max is y. Say max. 3.0
fit.Summary

Run test

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

अगर ३ का मान २ से ज्यादा है तो ३ बोलो. (If 3 is greater than 2, say 3)


com.aiaioo.VaklipiOutputFixture
program run()
अगर ३ का मान २ से ज्यादा है तो ३ बोलो. 3.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.

---