003. Technical interview question: Check number is even or odd without using arithmetic or relational operator

#include <stdio.h>
int main()
    int number;
    printf("Please input an integer number: ");
    scanf("%d", &number);
    //check 0th bit of number is 1 or 0
    (number & 0x01) ? printf("%d is an ODD Number.", number) :  printf("%d is an EVEN Number.", number) ;
    return 0;
Watch all videos like this

Leave a Reply

Your email address will not be published. Required fields are marked *