Differentiation of Operators in C Programming Language with Examples

Differences between & and && operators
&& is a logical AND operator. The output of this operation is
either 1 or 0. 1 represents the condition is TRUE and 0 represents the
condition is FALSE.
Example:
#include<stdio.h>
int main()
{
int a=10, b=11,c;
c= a && b;
printf("%d",c);
return 0;
}
Output: 1
& is a bitwise AND operator. The output of this operation is the combine
value after performing bitwise operation.
Example:
#include<stdio.h>
int main()
{
int a=10, b=11,c;
c= a & b;
printf("%d",c);
return 0;
}
Output: 10
Differences between | and || operators
|| is a logical OR operator. The output of this operation is either
1 or 0. 1 represents the condition is TRUE and 0 represents the
condition is FALSE.
Example:
#include<stdio.h>
int main()
{
int a=10, b=11,c;
c= a || b;
printf("%d",c);
return 0;
}
Output: 1
| is a bitwise OR operator. The output of this operation is the
combine value after performing bitwise OR operation.
Example:
#include<stdio.h>
int main()
{
int a=10, b=11,c;
c= a | b;
printf("%d",c);
return 0;
}
Output: 11
Differences between = and == operators
== is a logical EQUAL TO operator. The output of this operation
is either 1 or 0. 1 represents the condition is TRUE and 0
represents the condition is FALSE.
Example:
#include<stdio.h>
int main()
{
int a=10, b=11,c;
c= a == b;
printf("%d",c);
return 0;
}
Output: 0
= is an assignment operator. It assigns the value to its variable.
Example:
#include<stdio.h>
int main()
{
int a=10, b=11,c;
c= a = b;
printf("%d",c);
return 0;
}
Output: 11
Differences between < and << operators
< is a logical LESS THAN operator. The output of this operation is
either 1 or 0. 1 represents the condition is TRUE and 0
represents the condition is FALSE.
Example:
#include<stdio.h>
int main()
{
int a = 5, b = 4;
printf("%d\n", a<b);
return 0;
}
Output: 0
<< is a LEFT-SHIFT bitwise operator. It performs operation
based on Binary number system. This operator shifts binary 0 to left. The
number of shifted 0 depends on the value of operands in the right position
of this operator.
Example:
#include<stdio.h>
int main()
{
int a = 5;//BINARY 101
printf("%d\n", a<<1);//BINARY RESULT 1010
return 0;
}
Output: 10
Differences between > and >> operators
> is a logical GREATER THAN operator. The output of this operation is either 1 or 0. 1 represents the condition is TRUE and 0 represents the condition is FALSE.
Example:
#include<stdio.h>
int main()
{
int a = 5, b = 4;
printf("%d\n", a>b);
return 0;
}
Output: 1
>> is a RIGHT-SHIFT bitwise operator. It performs operation based on Binary number system. This operator shifts out binary 0 from the right. The number of shifted digits depends on the value of operands in the right position of this operator.
Example:
#include<stdio.h>
int main()
{
int a = 5;//BINARY 101
printf("%d\n", a>>1);//BINARY RESULT 10
return 0;
}
Output: 2