Operator, Operand, and Arithmetic

Today. we’ll talk about Operator, Operand and Arithmetic

  • Operator is a symbol to process values in result for a new value
  • Operand is part which specifies what data is to be manipulated or operated on
  • Example :

  C = A + B 

  (= and + sign are operators, A, B and C are operands)

  • Based on its operand number, operator can be divided into three:

–Unary operator  (needs one operand)

Binary operator  (needs two operands)

Ternary operator  (needs three operands)

Based on its operation type, operator can be grouped as:

–Assignment Operator

–Logical Operator

–Arithmetic Operator

–Relational Operator

–Bitwise Operator

–Pointer Operator

Assignment Operators

A binary operator

Used in assigning value to an operand

 

Left hand side operand (Operand1) should have (L-Value) such as variable

Right hand side operand (Operand2) can be constant, another variable, expression or function

Arithmetic Operators

Modulo

–Symbol : %

–Binary operator

–To find reminder of a division

–N % 2, can be used to find an odd or even number

  • N % 2 = 0 ® N is even
  • N % 2 = 1 ® N is odd
  • Increment and Decrement

–Symbol : ++(increment), –(decrement)

–Unary operator

–Increase (++) and decrease (–) the value of a variable by 1.

–Its position can be in the front (pre) or after (post) a variable.

Relational Operators

Use to compare to values with TRUE or FALSE result

FALSE in C language equals to the value of zero

TRUE on the other hand not equal to zero

TRUE set by a C program at run time equal to the value of one

 

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.