fork download
  1. #include <stdio.h>
  2. int main()
  3. {
  4. char str[1000], rev[1000];
  5. int i, j, count = 0;
  6. scanf("%s", str);
  7. printf("\nString Before Reverse: %s", str);
  8. //finding the length of the string
  9. while (str[count] != '\0')
  10. {
  11. count++;
  12. }
  13. j = count - 1;
  14.  
  15. //reversing the string by swapping
  16. for (i = 0; i < count; i++)
  17. {
  18. rev[i] = str[j];
  19. j--;
  20. }
  21.  
  22. printf("\nString After Reverse: %s", rev);
  23. }
Success #stdin #stdout 0s 5500KB
stdin
45
stdout
String Before Reverse: 45
String After Reverse: 542F�