hi.. I am suppose to write a recursive function that reverses the characters from s[j] to s[k] without changing the following main program:
Code:
int main (void) {
char phrase [] = "by the sea, by the beautiful sea";
rev (phrase,3,17);
printf ("%s\n",phrase);
return 0;
}
and the output is "by eht yb, aes eht beautiful sea"
I wrote the following program, but i had to change the main function! i dont know how to do it without changing the main! plz HELP!
Code:
# include <stdio.h>
void rev (char [],int,int);
int main () {
char phrase [] = "by the sea, by the beautiful sea";
rev (phrase,3,17); /* reverse the characters from phrase [3] to phrase [17] */
return 0;
}
void rev (char sen [],int start, int end)
{
if (end >= start)
printf ("%c",sen [end]);
rev (sen,start,end-1);
}