This is C Program to Reverse the String using Recursion. In this Program user ask to reverse the string with the use of recursion function. Char type variable is a casual call for containing the value. In this program majorly the reverse function will come in use and some where the use of if condition too. The first instance program asks to put the line of text. Then after the reverse function and so on but in next move the if condition comes to check the condition for reversing the string if it’s take right then the reverse function will reverse the function and then display the reversed content on the screen.
Problem Statement:
This is the program that reverses the string using recursion function.
- Declaring the Function.
- Entering the line of text.
- Using if condition.
- Display result on the screen.
Here is source code of the C program that reverses the string using recursion function. The C program is successfully compiled. The program output is also shown below.
#include<stdio.h>
void main()
{
void reverse(void);
clrscr();
printf("\nEnter a Line of Text : ");
reverse();
getch();
}
void reverse(void)
{
char c;
if((c=getchar())!='\n')
{
reverse();
putchar(c);
return;
}
}
Output :
Enter a Line of Text : Hello Dinesh
hseniD olleH