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;

}

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 las

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site