Monday 15 February 2016

Checking a number if it is Even or Odd using Bitwise Operator in C









#include <stdio.h>
#include <stdlib.h>
int main()
{
    int num;
    printf("Enter a number: ");
    scanf("%d", &num);
    if(num&1)
        printf("%d is ODD\n", num);
    else
        printf("%d is EVEN\n", num);
        system("pause");
    return 0;
}

Output"





 
 

No comments:

Post a Comment