Skip to content
Home » C Programs » C Program to Reverse a String Using Recursion

C Program to Reverse a String Using Recursion

Simple c program to reverse a string using recursion. In this program, we can execute the string reverse using the recursion function in the c programming language for beginners.

String Definition in C

A string, like an integer or a floating point unit, is a data type used in programming that is used to represent text rather than numbers. In C, a string (also known as a C string) is an array of characters followed by a NULL character. To represent a string, a group of characters is surrounded by double quotes (“).

Recursion Function in C Programming

Recursion is a process that occurs when a function calls a copy of itself to work on a smaller problem. Any function that calls itself is referred to as a recursive function, and such function calls are referred to as recursive calls. Recursion entails a large number of recursive calls. 

When a function calls a copy of itself in C, the process is referred to as recursion. To put it simply, when a function calls itself, this is referred to as recursion. When using recursion, you must define an exit condition on that function; otherwise, it will enter an infinite loop.

c program to reverse a string using recursion

//c program to reverse a string using recursion 
#include <stdio.h>
void reverser();
int main() 
{
printf("Enter The String");
reverser();
return 0;
}
void reverser() 
{
char c;
scanf("%c", &c);
if (c != '\n') 
{
reverser();
printf("%c", c);
}
}

Output:

Enter The Stringgoogle
elgoog