Tuesday, 21 February 2017

Finding bitwise AND of two numbers

QUESTION DESCRIPTION :

Write a program to find the bitwise AND of two decimal numbers.
An AND gate reads 2 input either 0 or 1 and outputs 1 iff both the inputs are 1. Similarly write a program to read two decimal numbers and finds AND of two numbers.
EXAMPLE :
(3)10 = (011)2
(5)10 = (101)2
AND of 3 and 4 is :
(1)10 = (001)2
TEST CASE 1

INPUT

12 23

OUTPUT

Bitwise AND of 12 and 23 is:4


EXPLANATION :

The code requires you to accept two inputs from the user and perform the AND & operation ( Bitwise Operators ) on them and print the result.


ALGORITHM : 

  • Input two integers from the user ( a,b )
  • Calculate the bitwise AND ( a&b )
  • Print the result with the required messages. 

SOLUTION : (Please use this as reference only)
CODE

No comments:

Post a Comment