Auto AdSense

Tuesday, 13 August 2013

C program to check whether given number x is equal to the value 2 POWER i or something, where i>=0 using BITWISE operators ONLY.




/* Check whether the given number x is equal to the value 2 power i or not using BITWISE
operators ONLY */
#include<stdio.h>
#include<conio.h>
void main(void)
{
long x;
clrscr();
printf("Enter a number : ");
scanf("%ld",&x);
if ((x & 0x1) == 0x0) 
printf("The given number %ld is EQUAL to the value 2 POWER something",x);
else
printf("The given number %ld is NOT EQUAL to the value 2 POWER something",x);
getch();
}

No comments:

Post a Comment