Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<cs50.h>
- #include<string.h>
- #include<ctype.h>
- int main (int argc , string argv[])
- {
- printf("please give me a key: ");
- int k = GetInt();
- printf("please enter a text : ");
- string s = GetString() ;
- for ( int i = 0 ; i < strlen(s) ; i++ )
- {
- int j =s[i] + k ;
- if (isalpha(s[i]))
- {
- if (isupper(s[i]))
- {
- j = (j % 26) ;
- printf("%c" , j + 'A');
- }
- if (islower(s[i]))
- {
- j = (j % 26) + 'a' ;
- printf("%c" , j ) ;
- }
- }
- }
- printf("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment