Thursday, September 13, 2018

FINDING OR OF TWO NUMBERS

  • Problem 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
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
     int a,b;
      scanf("%d%d",&a,&b);
      printf("Bitwise OR of %d and %d is=%d",a,b,a|b);
    return 0;
    }
  • Test Case 1

    Input (stdin)
    12
    
    23
    
    
    Expected Output
    Bitwise OR of 12 and 23 is=31
  • Test Case 2

    Input (stdin)
    12
    
    12
    
    
    Expected Output
    Bitwise OR of 12 and 12 is=12

No comments:

Post a Comment