There are 8 types of operators in C language: arithmetic, logical, bitwise, increment/decrement, relational, assignment, conditional, and special. The document provides details on each operator type, including their symbols and usage. It also includes examples of programs using various operators and their output.
5. Program
#include<stdio.h>
void main()
{
int x = 25 , y = 5
printf(“%d + %d = %dn”, x , y , x + y );
printf(“%d + %d = %dn”, x , y , x + y );
printf(“%d + %d = %dn”, x , y , x + y );
printf(“%d + %d = %dn”, x , y , x + y );
getch();
}
Output
25 + 5 = 30
25 – 5 = 20
25 * 5 = 125
25 / 5 = 5
8. Bitwise operator
Operator name Meaning
& Bit-wise AND
| Bit-wise OR
^ Bit-wise XOR
<< Left shift
>> Right shift
~ Bit-wise 1`s complement
9. increment and decrement operator
Increment means i++ or ++i
some example i=5 than i++ in result is 6
Decrement means i-- or --I
Some example i=5 than i– in result is 4
i++ and i-- is postfix
++i and --i is prefix
10. Relational operator
Operator name Meaning
== Equals
!= Not equals to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
11. Assignment operator
assignment operator symbol is =
assignment operator is used to value to variable
varname = varname operator expression ;
varname operator = expression;
Example
1. a = a + 5 ; a += 5;
12. Conditional operator
It is also knows as a ternary operator
it is used to
Expr1 ? Expr2 : expr3 ;
logical operator is true and false
expr2 is true is the print to the display and expr3 is not print
expr3 is true is the print to the display and expr2 is not print
14. Simple program
#include<stdio.h>
#include<conio.h>
void main()
{
int x = 10 , y , z = 0;
x++;
++x;
y = ++x;
printf(“value of x = %d y = %d and x = %dn”, x , y , z);
z = y--;
printf(“value of x = %d y = %d and x = %dn”, x , y , z);
getch();
}
Output
Value of x = 13 y = 13 and z =0
Value of x = 13 y = 12 and z = 13