Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<cs50.h>
- int main()
- {
- char input[100], ch;
- int i, key;
- printf("Enter a input to encrypt: ");
- input = get_string;
- printf("Enter key: ");
- scanf("%d", &key);
- for(i = 0; input[i] != '\0'; ++i){
- ch = input[i];
- if(ch >= 'a' && ch <= 'z'){
- ch = ch + key;
- if(ch > 'z'){
- ch = ch - 'z' + 'a' - 1;
- }
- input[i] = ch;
- }
- else if(ch >= 'A' && ch <= 'Z'){
- ch = ch + key;
- if(ch > 'Z'){
- ch = ch - 'Z' + 'A' - 1;
- }
- input[i] = ch;
- }
- }
- printf("Encrypted input: %s", input);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement