Monday 14 October 2019

Check whether 3 numbers are equal or not using bitwise operators

//Given 3 integers a,b,c. Find if all the 3 numbers are same or not using bitwise operators
#include<stdio.h>

int main() {
    int a,b,c,t;
    scanf("%d%d%d",&a,&b,&c);
    t=(a^b)|(b^c);
    if(t==0)
        printf("same");
    else
        printf("not same");
}

No comments:

Post a Comment