C: Gets all the even digits and odd digits in a binary sequence, outputting the binary sequence separately.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.