Thursday, September 13, 2018

FINDING BITWISE EXOR OF TWO NUMBERS


  • Problem Description

    Write a program to find the bitwise EXOR of two decimal numbers.
    An EXOR gate reads 2 input either 0 or 1 and outputs 0 if both the inputs are same and outputs 1 if both the inputs are different.
    Similarly write a program to read two decimal numbers and finds EXOR of two numbers .
    EXAMPLE :
    (3) 10 = (011) 2
    (5) 10 = (101) 2
    EXOR of 3 and 4 is :
    (6) 10 = (110) 2
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int a,b,c;
      scanf("%d%d",&a,&b);
      c=a^b;
      printf("Bitwise EX-OR of %d and %d is=%d",a,b,c);
      

    return 0;
    }
  • Test Case 1

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

    Input (stdin)
    2
    
    2
    
    
    Expected Output
    Bitwise EX-OR of 2 and 2 is=0

No comments:

Post a Comment