Sunday 20 May 2012

Write a program to find whether a given number is odd or even using bitwise AND operator.


//program to find whether  a number is odd or even by using bitwise AND operator
void main()
{
int a=1,num;
clrscr();
printf("Enter any number ");
scanf("%d",num);
if((num & a)==0)
printf("Number is even");
else
printf("Number is odd");
getch();
}
Output
Enter any number 25
          Number is odd 

No comments:

Post a Comment