Mathematical Operators are widely used in programming in case of problem solving; calculations will always be used for performing numerous tasks. The main mathematical operators are:

+ (Sum)

– (subtraction)

* (multiplication)

/ (division)

It is very important to know that, as in mathematics, operations in programming logic follow an order. There is an order of precedence between these operators:

  • First: () – parentheses;
  • Second, * (multiplication) and / (division), the one that first appear;
  • Third: + (sum) or – (minus), the one that first appear.

Relational operators are used to compare two values that can be variable or constant, of the same type. Examples of relational operators:

  • = (less than)
  • > (greater than)
  • <(less than)
  • <> (different from)
  • > = (greater than or equal to)
  • <= (less than or equal to)

These operators are often used and the result of these comparisons implies a logical value (true or false):

10> = 5 (true)

11 <> 11 (false)

0.5 <(-1) (false)

The A = (true)

Finally, the logical operators are combined to the expressions. Thus we got a true or false value. The main logical operators are:

  • AND – conjunction
  • Or – disjunction
  • No – denial

The “E” and “or” are binary operators. This means that they serve to combine two expressions. The “No” is a unary operator. This means that it serves to change the value of an expression. To better understand how they are used, see the following expressions:

  1. Has electricity;
  2. The computer is plugged in.

So that the computer turns on, you have to obey the two previous expressions. Imagine the following relationship:

(Expression 1) and (Expression 2)

If one of these expressions is not true, the condition is false (The computer does not start). The computer turns on only if both are true. The possibilities table of a condition is called Truth Table:

Expression 1 and Expression 2

FALSE FALSE FALSE

FALSE FALSE TRUE

TRUE FALSE FALSE

TRUE TRUE TRUE

The logical operators can be combined in countless ways. As mathematical, logical operators follow an order of precedence (priority):

  1. () – Parentheses.
  2. No – Denial.
  3. E – Conjunction.
  4. Or – disjunction

Visit our blog and check out more content!

By ,

January 25, 2016

a

You might also like…

AI-Driven Software Development: The Role of ChatGPT

In the rapidly evolving world of technology, artificial intelligence (AI) is playing an increasingl...

Low-Code: The Key to Accessible Digital Transformation

Digital transformation is imperative for companies wishing to remain competitive in the current era...

Low-code: Simplifying Development Without Sacrificing Quality

In today's agile and competitive world, productivity is crucial for the success of any business. Th...

You might also like…

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.