C Programming
Computer Programming

C program to Reverse a string using recursion



Write a program in C to Reverse a string using recursion

\* C program to Reverse a string using recursion *\

# include < stdio.h >
# include < conio.h >
void   reverseSentence( ) ;

int   main( )
{

printf("\n Enter a sentence : ") ;
reverseSentence() ;
return 0 ;

}

void   reverseSentence( )
{

char c ;
scanf("%c", &c ) ;
if( c != '\n' )
{
      reverseSentence() ;
      printf("%c", c) ;
}

}

Output of Program :

Output of C program to Reverse a string using recursion