Task: Reverse a string by recursively swapping outer characters moving inward. Print the reversed string.
#include <stdio.h>
int my_len(const char s[]){ int n=0; while(s[n]) ++n; return n; }
void rev_rec(char s[], int l, int r){ if(l>=r) return; char t=s[l]; s[l]=s[r]; s[r]=t; rev_rec(s,l+1,r-1); }
int main(void){
char s[256]; int c,i=0;
printf("Enter a string: ");
while((c=getchar())!='\n' && c!=EOF){ if(i<255) s[i++]=(char)c; } s[i]='\0';
rev_rec(s, 0, my_len(s)-1);
printf("Reversed: %s\n", s);
return 0;
}