# Difference Between & and &&

Computer ProgrammingProgrammingMiscellaneous

In this post, we will understand the difference between the ‘&’ and ‘&&’ operators.

## & operator

• It is a bitwise operator.

• It evaluates the left and right side of the expression.

• It operates on the ‘Boolean’ datatype (True or False).

• It also operates on bits.

• It is used to check the logical conditions.

• It can also be used to mask off specific bits (like the parity bits).

## Example

#include<stdio.h>
int main(){
int x = 3;
int y = 4;
int z = x & y;
printf ("z = %d", z);
return 0;
}

## && operator

• It is a logical operator.

• It evaluates the left side of the expression only.

• It operates on ‘Boolean’ datatype only.

• It is used to check the logical conditions.

## Example

#include<stdio.h>
int main(){
int a = 6, b = 3;
printf("%d", a&&b);
return 0;
}
Published on 24-Mar-2021 18:06:33