If any operation perform on two operands is known as binary operators .These are classified into following types
- Arithmetic
- Assignment
- Relational
- Logical
- Bitwise
Arithmetic Operators : If any operation perform on Arithmetic values is known as arithmetic operators .These are classified into following types
| Operator | Example |
| + (Addition) | a+b |
| - (Substruction) | a-b |
| * (Multiplication) | a*b |
| / (Division) | a/b |
| % (Modular Division) | a%b |
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,z;
printf("Enter x ,y values");
scanf("%d%d",&x,&y);
z=x+y;
printf("Addition is %d",z);
getch();
}
Assignment Operators : Assignment operators are used to assign the values to the variable or assign the variable to variable .These are classified into following types
| Operator | Example | Same as |
| = | a=b | a=b |
| += | a+=b | a=a+b |
| -= | a-=b | a=a-b |
| *= | a*=b | a=a*b |
| /= | a/=b | a=a/b |
| %= | a%=b | a=a%b |
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y;
printf("Enter x ,y values");
scanf("%d%d",&x,&y);
x=x+y;
printf("Addition is %d",x);
getch();
}
Relational Operators : Relational operators are used to check the relation between two variables .These are classified into following types
| Operator | Example |
| == | a==b |
| > | a>b |
| < | a<b |
| >= | a>=b |
| <= | a<=b |
| != | a!=b |
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,z;
printf("Enter x ,y values");
scanf("%d%d",&x,&y);
z=x>y;
printf("The Relation of x>y is %d",z);
getch();
}
Nore :Relational operators are used in conditional statements only
Logical Operators : Logical operators are used to combine the morethan one condition .These are classified into following types
| Operator | Example |
| Logical AND && | a>b && a>c |
| Logical OR || | a>b || a>c |
| Logical NOT ! | !(a>b && a>c) |
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,z,p;
printf("Enter x , y, z values");
scanf("%d%d%d",&x,&y,&z);
p=(x>y && x>z);
printf("The Logical AND is %d",p);
getch();
}
Nore :Logical operators are used in conditional statements only
Bitwise Operators : Bitwise operators are used to perform any operation on binary values .These are classified into following types
| Operator | Example |
| Bitwise AND & | a&b |
| Bitwise OR | | a|b |
| Bitwise CAP ^ | a^b |
| Bitwise NAGETION ~ | ~a |
| Bitwise LEFT SHIFT << | a<<b |
| Bitwise Right SHIFT >> | a>>b |
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,z;
printf("Enter x , y values");
scanf("%d%d",&x,&y);
z=x&y;
printf("The Bitwise AND is %d",z);
getch();
}