Last active
February 6, 2019 12:18
-
-
Save KeitetsuWorks/1bf10ea6a042c9afd15abf32518cb6c5 to your computer and use it in GitHub Desktop.
unsigned int型で入力された整数値の32ビットの2進表示をするプログラム
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @file q14203071524.c | |
| * @brief unsigned int型で入力された整数値の32ビットの2進表示をするプログラム | |
| * @author Keitetsu | |
| * @date 2019/02/06 | |
| * @copyright Copyright (c) 2019 Keitetsu | |
| * @par License | |
| * This software is released under the MIT License. | |
| */ | |
| #include <stdio.h> | |
| #define ID "q14203071524" | |
| #define NAME "ID非公開さん" | |
| int main(void) | |
| { | |
| /* | |
| * unsigned int型で入力された整数値の32ビットの2進表示をするプログラム | |
| * たとえば,12345678が入力された場合,00000000101111000110000101001110と表示する. | |
| */ | |
| int i; | |
| unsigned int x; /* 入力値 */ | |
| printf("x = "); | |
| scanf("%u", &x); | |
| printf("%u = B'", x); | |
| for (i = 32; i > 0; i--) { | |
| printf("%d", (x >> (i - 1)) & 0x00000001); | |
| } | |
| printf("\n"); | |
| printf("ID: %s, NAME: %s\n", ID, NAME); | |
| return 0; | |
| } // end of main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment