Describe the various types of operators in „C‟ language along with its priority.
An ex pr e s s I o n is a sequence of operators and operands that specifies computation of a value, or that designates an object or a function, or that generates side effects, or that performs a combination thereof.
1. ARITHMETIC OPERATORS:
The symbols of the arithmetic operators are:-
Example:
#include <stdio.h>
main()
{
int sum = 50; float modulus; modulus = sum % 10;
printf(“The %% of %d by 10 is %f\n”, sum, modulus);
}
PRE/POST INCREMENT/DECREMENT OPERATORS
PRE means do the operation first followed by any assignment operation. POST means do the operation after any assignment operation. Consider the following statements ++count; /* PRE Increment, means add one to count */ count++; /* P OST Increment, means add one to count */
Example:
#include <stdio.h>
main()
{
int count = 0, loop;
loop = ++count; /* same as count = count + 1; loop = count; */
printf(“loop = %d, count = %d\n”, loop, count);
loop = count++; /* same as loop = count; count = count + 1; */
printf(“loop = %d, count = %d\n”, loop, count);
}
If the operator precedes (is on the left hand side) of the variable, the operation is performed first, so the statement
loop = ++count;
really means increment count first, then assign the new value of count to loop.
2. THE RELATIONAL OPERATORS
These allow the comparison of two or more variables.
= = equal to
! = not equal
< less than
< = less than or equal to
> greater than
> = greater than or equal to
Example:
#include <stdio.h>
main() /* Program introduces the for statement, counts to ten */
{
int count;
for( count = 1; count <= 10; count = count + 1 )
printf(“%d “, count );
printf(“\n”);
}

