Here is source code of the C Program to check whether the given integer has an alternate pattern. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C Program to Check whether the given Integer has an Alternate
int num, x, y, count = 0;
printf("enter the number:");
x = num << 1;
y = x ^ num;
y = y + 1;
/* Checks if the number is in powers of 2 */
while ((y / 2) != 0)
if (y % 2 != 0)
y = y / 2;
$ cc bit16.c $ a.out enter the number:85 true $ a.out enter the number:87 false
Sanfoundry Global Education & Learning Series – 1000 C Programs.