C program to find even or odd using bitwise operator

 #include<stdio.h>

int main()
{
    int n;
    printf("enter the number\n");
    scanf("%d",&n);
    if(n&0x01)
    printf("odd number\n");
    else
        printf("even number\n");
}

Output:
enter the number
2
even number

No comments:

Post a Comment