fork download
  1. #include <stdio.h>
  2. int main() {
  3. char s[1000];
  4. int shift, i;
  5.  
  6. printf("Enter text: ");
  7. fgets(s, 1000, stdin);
  8.  
  9. printf("Enter shift: ");
  10. scanf("%d", &shift);
  11.  
  12. for (i = 0; s[i] != '\0'; i++) {
  13. char c = s[i];
  14. if (c >= 'A' && c <= 'Z') {
  15. s[i] = ((c - 'A' + shift) % 26) + 'A';
  16. }
  17. else if (c >= 'a' && c <= 'z') {
  18. s[i] = ((c - 'a' + shift) % 26) + 'a';
  19. }
  20. }
  21.  
  22. printf("Output: %s", s);
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
Enter text: Enter shift: Output: PHbr�