Operators and Expression

In the previous chapter we have learnt about basic concept of Variables and Constants, In this chapter we are going to learn about the OPERATORS AND EXPRESSION in C Programming.

OPERATORS

In Computer programming operator is a symbol which performs specific action on its operands and gives desired output.

Example:
“a + b”, Here a and be are the operands and “+” is the operator which perform specific action. i.e Addition of two operand value.

Expression:

An expression in a programming language like C is the combination of variable, constants, operators and functions which computes to yield output.

Example: a+b, 7+3 a+5 etc

Based on the number of operand used for an operator it is classified into three categories:

  1. unary operator
  2. binary operator
  3. ternary operator

Depending upon the type of operations to be performed by the operators, it can be classified into following categories:

  1. arithmetic operator
  2. assignment operator
  3. relational operator
  4. Logical operator
  5. conditional operator
  6. increment and decrement operator
  7. comma operator
  8. sizeof operator
  9. bitwise operator

Arithmetic operators:

Arithmetic operators are used to perform arithmetic operation like addition, subtraction, product etc.
OPERATORS

Unary arithmetic operator:

This operator require only one operand to perform arithmetic operation and yield output.
Example: +p   -q
Here p and q are operand + and – are unary operators which are changing the sign of operand p and q respectively.
Note: unary operators are different from binary + and – operator.

Binary operator:

Those arithmetic operators which require two operand to perform arithmetic operation is called binary arithmetic operators.
Binary arithmetic operators are of following types:

OPERATOR USING PURPOSE
+ Addition
Subtraction
% to get remainder
/ Division
* multiplication

Note:
In arithmetic integer if the numerator or denominator sign varies from each other in that situation result is implantation dependent.
Modulus operator (%) must not be used with floating point numbers (float, double, long double) because there is no exponent operator in C, but there is a library function pow() which can carry out these type of operation.

/* THIS PROGRAM MAKE YOU UNDERSTAND ABOUT THE ARITHMETIC INTEGER OPERATION */

output:

/* THIS PROGRAM MAKE YOU UNDERSTAND ABOUT FLOATING POINT ARITHMETIC OPERATION*/

output:

in the above code we don’t considered modulus operation because it cannot be operated with floating point number(as discussed above).
If any one of the input given by user will be of integer type in that case also result will be of floating type:
eg.
Click here for more related tutorials.

                                                                                                  

 

2 thoughts on “Operators and Expression”

  1. Pingback: buy fifa points

Leave a Reply