C Program to Reverse a String Using Recursion Last Updated : 15 Dec, 2024 Suggest changes Share Like Article Like Report Reversing a string means changing the order of characters in the string so that the last character becomes the first character of the string. In this article, we will learn how to reverse a string using recursion in a C program.The string can be reversed by using two pointers: one at the start and one at the end. Swap the values of these two pointers while moving the pointers towards each other. Let’s take a look at an example: C #include <stdio.h> #include <string.h> // Function to reverse string using recursion void revRecursive(char *l, char *r) { // Till two pointers do not meet, // swap the values they point to if (l != r) { char c = *l; *l = *r; *r = c; // Recursive call revRecursive(l + 1, r - 1); } } // Wrapper function void rev(char *s) { // Calling the recursive function revRecursive(s, s + strlen(s) - 1); } int main() { char s[] = "GeeksforGeeks"; // Reversing the string s rev(s); printf("%s", s); return 0; } OutputskeeGrofskeeG Advertise with us Next Article C Program to Reverse a String Using Recursion K kartik Follow Similar Reads C Program to Reverse a Stack using Recursion Write a program to reverse a stack using recursion, without using any loop. Example: Input: elements present in stack from top to bottom 1 2 3 4 Output: 4 3 2 1 Input: elements present in stack from top to bottom 1 2 3Output: 3 2 1 Recommended PracticeReverse a StackTry It!Reverse a stack using Re 5 min read C Program to reverse the digits of a number using recursion Given an integer N, the task is to reverse the digits of given integer using recursion. Examples: Input: N = 123Output: 321Explanation:The reverse of the given number is 321. Input: N = 12532Output: 23521Explanation:The reverse of the given number is 23521. Approach: Follow the steps below to solve 2 min read How to Reverse a String in C? In C, a string is a sequence of characters terminated by a null character (\0). Reversing a string means changing the order of the characters such that the characters at the end of the string come at the start and vice versa. In this article, we will learn how to reverse a string in C. Example: Inpu 2 min read C Program To Reverse Words In A Given String Example: Let the input string be "i like this program very much". The function should change the string to "much very program this like i" Examples: Input: s = "geeks quiz practice code" Output: s = "code practice quiz geeks" Input: s = "getting good at coding needs a lot of practice" Output: s = " 3 min read C# Program To Reverse Words In A Given String Example: Let the input string be "i like this program very much". The function should change the string to "much very program this like i" Examples: Input: s = "geeks quiz practice code" Output: s = "code practice quiz geeks" Input: s = "getting good at coding needs a lot of practice" Output: s = "p 4 min read Article Tags : C Programs C Language C Strings Programs Like