The & (bitwise AND) in C or C++ **takes two numbers as operands and does AND on every bit of two numbers**. The result of AND is 1 only if both bits are 1. The | (bitwise OR) in C or C++ takes two numbers as operands and does OR on every bit of two numbers. The result of OR is 1 if any of the two bits is 1.

**There are three formulas to calculate income from operations:**

- Operating income = Total Revenue – Direct Costs – Indirect Costs. OR.
- Operating income = Gross Profit – Operating Expenses – Depreciation – Amortization. OR.
- Operating income = Net Earnings + Interest Expense + Taxes. Sample Calculation.

A bitwise operator is an operator used **to perform bitwise operations on bit patterns or binary numerals that involve the manipulation of individual bits**. Bitwise operators are used in: Communication stacks where the individual bits in the header attached to the data signify important information.

The bitwise AND operator ( & ) **compares each bit of the first operand to the corresponding bit of the second operand**. If both bits are 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0. Both operands to the bitwise AND operator must have integral types.

The result of the bitwise Exclusive-OR operation is **1 if only one of the expression has the value as 1**; otherwise, the result is always 0. As we can see, two variables are compared bit by bit.

The **bitwise-AND** operator compares each bit of its first operand to the corresponding bit of its second operand. If both bits are 1, the corresponding result bit is set to 1.

It is used in simple digital addition circuits which **calculate the sum and carry of two (half-adder) or three (full-adder) bit numbers**. XOR gates are also used to determine the parity of a binary number, i.e., if the total number of 1's in the number is odd or even.

The bitwise operators are the operators used to perform the operations on the data at the bit-level.

Bitwise Operator in C.

Operator | Meaning of operator |
---|---|

| | Bitwise OR operator |

^ | Bitwise exclusive OR operator |

~ | One's complement operator (unary operator) |

<< | Left shift operator |

Whereas, **Definition of a variable says where the variable gets stored**. i.e., memory for the variable is allocated during the definition of the variable.

Difference between Definition and Declaration.

Declaration | Definition |
---|---|

A variable or a function can be declared any number of times | A variable or a function can be defined only once |

Difference Between Definition and Declaration

It aims at determining the overall values stored in a class, a function, or a variable. It aims at specifying the name of any given class, function, variable, etc. **Definition allocates memory to an entity.** **A declaration does not allocate memory to the entities**.

Which of the following bitwise operations will you use to set a particular bit to 0? Explanation: **1 AND 0 = 0, 0 AND 0 = 0**, any bit AND with 0 gives 0.

The & (bitwise AND) in C or C++ **takes two numbers as operands and does AND on every bit of two numbers**. The result of AND is 1 only if both bits are 1. The | (bitwise OR) in C or C++ takes two numbers as operands and does OR on every bit of two numbers. The result of OR is 1 if any of the two bits is 1.

Answer: **Variable declaration tells the compiler about data type and size of the variable.** **Whereas, variable definition allocates memory to the variable**. Variable can be declared many times in a program. But, definition can happen only one time for a variable in a program.

Explanation: Bitwise operator **|** can be used to “set” a particular bit while bitwise operator & can be used to “reset” a particular bit.

The output of bitwise OR is **1 if at least one corresponding bit of two operands is 1**. In C Programming, bitwise OR operator is denoted by |.

Bitwise operators are **characters that represent actions to be performed on single bits**. A bitwise operation operates on two-bit patterns of equal lengths by positionally matching their individual bits: A logical AND (&) of each bit pair results in a 1 if the first bit is 1 AND the second bit is 1.

. Is correct. 16 >>> 2 = **4**.

To find each bit of XOR just **calculate number of 1's in the corresponding bits**. If it is even or zero then that XOR'ed bit is 0. If it is odd then that XOR'ed bit is 1.

When both inputs are equal, either are 1 or both are 0, the output will be logical 0. This is the reason an XOR gate is also called an anti-coincidence gate or inequality detector. This gate is called XOR or exclusive OR gate because **its output is only 1 when its input is exclusively 1**.

Online Test

645. | What is the output of Exclusive OR ^ operator on 0110^1000? |
---|---|

a. | 1000 |

b. | 1110 |

c. | 0011 |

d. | 0001 |

Dated : 09-Jul-2022

Category : Education