Lipi

Logical Expressions

Logical expressions in Lipi are used to combine or negate conditions, resulting in a boolean value (thik or bethik).

Syntax

logical_term { ("&&" | "||" | "!" ) logical_term }

Logical AND (&&)

The logical AND operator (&&) returns thik if both operands are thik, otherwise it returns bethik.

purna age;
purna income;

age = 25;
income = 50000;

yadi(age >= 18 && income >= 30000) {
  bhana("You are eligible for a loan.");
}anyatha {
  bhana("You are not eligible for a loan.");
}

Logical OR (||)

The logical OR operator (||) returns thik if at least one of the operands is thik, otherwise it returns bethik.

purna temperature;
temperature = 38;

yadi(temperature <= 0 || temperature >= 30) {
  bhana("Extreme temperature detected!");
}anyatha {
  bhana("Normal temperature.");
}

Logical NOT (!)

The logical NOT operator (!) returns thik if the operand is bethik, and bethik if the operand is thik.

purna isRaining;
isRaining = thik;

yadi(!isRaining) {
  bhana("It's not raining.");
}anyatha {
  bhana("It's raining.");
}

Complex Logical Expressions

You can combine multiple logical operators to create complex conditions:

purna age;
purna income;
purna creditScore;

age = 25;
income = 50000;
creditScore = 750;

yadi((age >= 18 && income >= 30000) || creditScore >= 700) {
  bhana("You are eligible for a loan.");
}anyatha {
  bhana("You are not eligible for a loan.");
}

Next Steps

Now that you understand logical expressions in Lipi, you can learn more about: