C String mash recursion Have a user input a string Then disp
C++
String mash (recursion):
Have a user input a string. Then display this string smashed up as follows: display the first character in the string, then the last, then the second, then the second to last, then the third... So if the string is “abcdef”, it will display: afbecd (input “abcdef”)
Solution
# include <stdio.h>
/* Function to print reverse of the passed string */
void reverse(char *str)
{
if (*str)
{
reverse(str+1);
printf(\"%c\", *str);
}
}
/* Driver program to test above function */
int main()
{
char a[] = \"abcdef\";
reverse(a);
return 0;
}
