Print a string backwards using recursion : function recursion « Function « C++ Tutorial






#include <iostream> 
using namespace std; 
 
void f(char *s); 
 
int main() 
{ 
  char str[] = "this is a test"; 
 
  f(str); 
 
  return 0; 
} 
 
void f(char *s) 
{ 
  if(*s)  
    f(s+1);  
  else 
    return; 
 
  cout << *s; 
}
tset a si siht








7.11.function recursion
7.11.1.Demonstrate recursion
7.11.2.Print a string backwards using recursion
7.11.3.Recursive factorial function
7.11.4.The recursive fibonacci function.
7.11.5.The iterative factorial method.