Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main()
- {
- char keyinput[127];
- int defaultkey;
- int bit;
- int k;
- printf("Enter Your Key. Number between 1 & 127.\n");
- fgets(keyinput, 127, stdin);
- int usekey = atoi(keyinput);
- printf("%d\n", usekey);
- if(usekey >= 1 && usekey < 127)
- {
- printf("The Key You Are Using Is %d\n", usekey);
- }
- else if (usekey > 127)
- {
- usekey = 101;
- printf("Number Entered For Key Is To Big. Using Defaultkey %d\n", usekey);
- }
- else
- {
- usekey = 101;
- printf("No Key Was Entered. Using Default Key %d\n", usekey);
- }
- //now turn this number into binary
- for (bit = 7; bit >= 0; bit--)
- {
- k = usekey >> bit;
- if (k & 1)
- printf("1");
- else
- printf("0");
- }
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment