# What is the difference between & and && in C?

## Difference between & and &&

What is the difference between & and && in C? - In this section, we will explain difference between & and && operators in C programming language. Here Operator & is Bitwise AND and Address of Operator, while && is Logical AND Operator.

#### & as "Address of" Operator

Operator & is a Unary Address Of Operator which returns address of a variable. Basically & is used two times when we are storing values in variable and print the address of any variable.

Consider the following code snippet
```scanf("%d",&num);

```

In the first statement integer value will be stored in num because &num pointing the address of variable num.

In the second statement address of num will print.

#### & as "Bitwise AND" Operator

Bitwise AND Operator (&) is Binary Operator because it operates on two operands and used for Bitwise AND operation.

Consider the following code snippet
```int x=3;
if(x&1)
printf("ONE");
if(x&2)
printf("TWO");

```

In this statement value of x is 3, so both bits are 1, condition (x&1) and (x&2) will be true and "ONETWO" both messages will print.

#### Logical AND Operator (&&)

Logical AND (&&) is a Binary Operator which is used to check more than one conditions at a time and if all conditions are true result will be true.

Consider the following code snippet
```int x=10;
int y=20;

if(x==10 && y==20)
printf("TRUE");
else
printf("FALSE");

```

In this statement both conditions x==10 and y==20 are true, hence "TRUE" will print.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates