0
1.3kviews
Which bitwise operator is used to multiply the number by 2^n where n is number of bits.

A] Bitwise-OR B] Bitwise-AND C] Bitwise-left shift D] Bitwise-right shift.

Subject : Structured Programming Approach

Title : Fundamentals Of C-Programming

1 Answer
0
13views

* Which bitwise operator is used to multiply the number by 2^n where n is number of bits.*
A] Bitwise-OR B] Bitwise-AND C] Bitwise-left shift D] Bitwise-right shift.

Ans:- C] Bitwise-left shift
Explanation
The left shift operator shift the bits left by 1 this doubles the previous number.
1. Code :-

a=2
print(a<<1)

Output:-
4
Explanation:-Here the value of a is 2 after shifting the bits to the left once it doubles the no so double of 2 is 4

2. Code :-

a=2
print(a<<2)

Output:- 8
Explanation:-Here the value of a is 2 here the left shift takes place twice i.e. 2 is doubled 1st which results into 4 then for the 2nd time 4 is doubled which results into 8

Please log in to add an answer.