Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(){
- int input = 0;
- int buffer = 0;
- int i = 0;
- int four = 0;
- int value = -1;
- //while(1){
- printf("Ganzzahl eingeben: ");
- value = scanf("%d", &input);
- while(value == 0){
- printf(" Bitte Zahl eingeben!\n");
- printf("Ganzzahl eingeben: ");
- value = scanf("%d", &input);
- }
- // input = -1;
- printf("%d in Hexadezimaldarstellung:\n %X\n", input, input);
- printf("%d in Binärdarstellung:\n ", input);
- for(i = 31; i >= 0; i--){
- buffer = input >> i;
- if(buffer & 1){
- printf("1");
- four++;
- }
- else{
- printf("0");
- four++;
- }
- if(four % 4 == 0){
- printf(" ");
- }
- }
- printf("\n");
- //}
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement