rahulb5

Untitled

Apr 19th, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<cs50.h>
  3. #include<string.h>
  4. #include<ctype.h>
  5.  
  6. int main (int argc , string argv[])
  7. {
  8. printf("please give me a key: ");
  9. int k = GetInt();
  10. printf("please enter a text : ");
  11. string s = GetString() ;
  12. for ( int i = 0 ; i < strlen(s) ; i++ )
  13. {
  14. int j =s[i] + k ;
  15. if (isalpha(s[i]))
  16. {
  17. if (isupper(s[i]))
  18. {
  19. j = (j % 26) ;
  20. printf("%c" , j + 'A');
  21. }
  22. if (islower(s[i]))
  23. {
  24. j = (j % 26) + 'a' ;
  25. printf("%c" , j ) ;
  26. }
  27. }
  28.  
  29. }
  30. printf("\n");
  31. }
Advertisement
Add Comment
Please, Sign In to add comment