Reverse a String in C17 Mar 2025 | 6 min read This topic will discuss several ways to reverse a string in the C programming language. Reversing a string is the technique that reverses or changes the order of a given string so that the last character of the string becomes the first character of the string and so on. Furthermore, we can also check the Palindrome of the given string by reversing the original string. For example, we enter a string "APPLE", and then use the reverse algorithm. The reverse algorithm returns the string "ELPPA" which is completely reverse of the original string. ![]() Different ways to find the reverse of a string in the CFollowing are the various ways to find the reverse of a string in the C programming language:
Program 1: Print the reverse of a string using strrev() functionLet's consider an example to print the reverse of a string using the strrev() function. Program1.c Output Enter a string to be reversed: AMBULANCE After the reverse of a string: ECNALUBMA Program 2: Print the reverse of a string without using the library functionLet's consider an example to print the reverse of a string using user defined function. Program2.c Output Enter the string: Welcome Friends Before reversing the string: Welcome Friends After reversing the string: sdneirF emocleW Program 3: Print the reverse of a string using the recursion functionLet's consider an example to print the reverse of a string using the recursion function. Recursion function: A recursion function is a function that continuously calls the same function without using a looping statement. Program3.c Output Enter the string: LIFE INSURANCE Before reversing the string: LIFE INSURANCE After reversing the string: ECNARUSNI EFIL Program 4: Print the reverse of a string using for loopLet's consider an example to print the reverse of a string using for loop in C programming language. Program4.c Output Display a reverse string in the C: ----------------------- Enter a string to reverse order: APPLE The reverse of the original string is: ELPPA Program 5: Print the reverse of a string using while loopLet's consider an example to print the reverse of a string using while loop in C programming language. Program5.c Output Enter a string to be reversed: JAVATPOINT The reversed of the string: TNIOPTAVAJ Program 6: Print the reverse of a string using pointersLet's consider an example to print the reverse of a string using pointers in the C programming language. Program6.c Output Enter a string to be reversed: JAVATPOINT The reverse string is: TNIOPTAVAJ Program 7: Program to check whether the reverse string is a PalindromeConsider a program to check whether the given string is a palindrome or not in the C programming language. Program7.c Output Enter a string: madam madam is a palindrome string. Next TopicTwin Prime Numbers in C |
In this article, we will discuss the lseek() function with its syntax, parameter, example, advantages, and disadvantages. lseek () is a function in the C programming language that permits you to move the file pointer to a detailed position within a report. The record pointer represents the...
9 min read
C programming language is a widely used high-level programming language that is popular in the development of operating systems, application software, and system software. Embedded C is a variant of C that is specifically designed for programming embedded systems, such as microcontrollers, microprocessors, and other programmable...
7 min read
The va_start is a macro defined in the stdarg header file in the C Programming languages. The va_start() function is used to initialize the argument list. The argument list is referred to by ap. Initializing the argument list is necessary before using the va_arg() and va_end()...
4 min read
In this topic, we will discuss the LCM and how we can get the LCM of two numbers in the C programming language. LCM is a mathematical term that stands for Least Common Multiple (LCM). It is the smallest positive number that is completely divisible by both...
4 min read
Finding pieces within a collection is a typical task in the world of programming. The linear search is one of the most elementary and basic search methods. The specifics of the linear search will be covered in this blog post, along with its implementation in...
3 min read
In this article, we are going to discuss the range of int in C with programs. Range of Int Data types, and their size and range, play an important role in C programming. The sizeof() operator gives the number of bytes required to store a value in memory...
5 min read
Introduction: Strings are an essential component of programming, because they make it possible to communicate with users, show results, and read files. They are a type of data entry and output mechanism. Since strings are constantly used in some capacity in the programs we create, efficient handling...
3 min read
In C programming, handling input and output activities is essential. Fgets() is one of the many functions that are available for input. With the help of this robust function, developers may securely and precisely read information from a given stream. In this article, we will examine...
3 min read
Using the preprocessor directives and macros, reusable code snippets can be defined in C programs. You can construct more intricate code structures that span multiple lines with multiline macros. They are very helpful when writing compound statements or code blocks that will be utilized repeatedly throughout...
6 min read
All variables in a C program have a memory address and are stored in memory. However, the register keyword implies that the compiler should store the variable in a CPU register as opposed to memory. If you're unaware, a processor only has a certain number of...
3 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India