Tuesday, 21 February 2017

Finding OR of two numbers

QUESTION DESCRIPTION :

Write a program to find the bitwise OR of two decimal numbers.
An OR gate reads 2 input either 0 or 1 and outputs 0 iff both the inputs are 0 else 1. Similarly write a program to read two decimal numbers and finds OR of two numbers.

EXAMPLE :
(3) 10 = (011) 2
(5) 10 = (101) 2
OR of 3 and 4 is :
(7) 10 = (111) 2


TEST CASE 1

INPUT

12
23

OUTPUT

Bitwise OR of 12 and 23 is=31


EXPLANATION :

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


ALGORITHM : 

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

SOLUTION : (Please use this as reference only)

CODE

No comments:

Post a Comment