-
-
Save anonymous/346d631814c54fb90263 to your computer and use it in GitHub Desktop.
This file contains 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
int E1 () { | |
unsigned char a, b, c; | |
printf("Number (byte): "); | |
scanf("%hhd", &a); // This now only uses 1 byte (length of char) | |
printf("Bit you want to output (between 0 and 7): "); | |
scanf("%hhd", &b); // This now only uses 1 byte (length of char) | |
b = (1 << b); // This is more efficient for calculating 2^b | |
printf("Mask is: %d\n", b); | |
c= a & b; | |
if (c > 0) { | |
printf("The bit is: 1\n"); | |
} else { | |
printf("The bit is: 0\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment