C Program to Reverse a String Using Recursion Last Updated : 15 Dec, 2024 Comments Improve Suggest changes 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 Comment More infoAdvertise with us Next Article C Program to Reverse a String Using Recursion kartik Follow Improve Article Tags : C Programs C Language C Strings Programs 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 Reverse String in C In C, reversing a string means rearranging the characters such that the last character becomes the first, the second-to-last character becomes the second, and so on. In this article, we will learn how to reverse string in C.The most straightforward method to reverse string is by using two pointers t 3 min read C Program to Print the Length of a String using Pointers C language provides a built-in function strlen() but in this article, we will learn how to find and print the length of the string using pointers in C.The easiest method to find the length of a string using pointers is by calculating difference between the pointers to the first and last character of 2 min read Substring Reverse Pattern Given string str, the task is to print the pattern given in the examples below: Examples: Input: str = "geeks" Output: geeks *kee* **e** The reverse of "geeks" is "skeeg" Replace the first and last characters with '*' i.e. *kee* Replace the second and second last character in the modified string i.e 5 min read C Program to Traverse an Array in Reverse Write a C program to traverse a given array in reverse order that contains N elements.ExamplesInput: arr[] = {2, -1, 5, 6, 0, -3}Output: -3 0 6 5 -1 2Input: arr[] = {4, 0, -2, -9, -7, 1}Output: 1 -7 -9 -2 0 4Different Ways to Traverse an Array in Reverse Order in CWe can traverse/print the array in 2 min read How to Convert an Integer to a String in C? In C, integers can be represented as strings with each digit represented by corresponding numeric character. In this article, we will learn how to convert integers into the stringExamplesInput: 1234Output: "1234"Explanation: The integer 1234 is converted to the string "1234".Input: -567Output: "-567 3 min read Like