Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int reverse(char s[], int i, int j)
- {
- int temp;
- if(j == 1)
- return 1;
- else
- temp = s[i];
- s[i] = s[j];
- s[j] = temp;
- reverse(s, ++i, --j);
- /* recursively i am calling the same function but
- i am changing the values of the numbers*/
- }
- main()
- {
- char text[] = "Hello";
- printf("Not reversed text: %s\n", text);
- reverse(text, 0, strlen(text)-1);
- printf("Reversed text: %s\n", text);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement