Gets all the even digits and odd digits in a binary sequence, outputting a binary sequence respectively.
Program:
#include <stdio.h>
int Main ()
{
int I, J, num;
Char arr1[16];
Char arr2[16];
printf ("Enter an integer:");
scanf ("%d", &num);
for (i = 0, j = 0; i <; i + = 2, j + +)
{
arr1[15-j] = (num >> i) & 1; //forward storage from back
}
for (j = 0, J <; J + +)
{
printf ("%d", Arr1[j]);
}
printf ("\ n");
for (i = 1, j = 0; i <; i + = 2, j + +)
{
ARR2[15-J] = (num >> i) & 1;
}
for (j = 0, J <; J + +)
{
printf ("%d", Arr2[j]);
}
printf ("\ n");
return 0;
}
Results:
Enter an integer:2
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Please press any key to continue ...
This article is from the "Rock Owl" blog, please be sure to keep this source http://10742111.blog.51cto.com/10732111/1718366
C: Gets all the even digits and odd digits in a binary sequence, outputting the binary sequence separately.