#include <stdio.h> #include <string.h> void reverse(char str[], int, int); int main() { int size = 0; char str[20]; printf ("Enter the your string \n"); scanf ("%s", str); size = strlen(str); reverse(str, 0, size - 1); printf ("String after reverse : %s\n", str); return 0; } void reverse(char str[], int index, int size) { char temp; temp = str[index]; str[index] = str[size - index]; str[size - index] = temp; if (index == (size / 2)) { return; } reverse(str, index + 1, size); }
Comments
Post a Comment