C Program To Reverse a String Using STRREV Function

C Program to Reverse a String

C Program To Reverse a String – If you are looking for reversing a string in C program, this article will guide you to learn how to reverse a string in C. Just go through this reverse string tutorial you will be able to write a program to reverse sting.

CodingCompiler.com publishing series of easy to complex C programs for beginners, students, B.Tech graduates to enhance their C programming skills and hands-on experience on coding. This is the fourth C programming example in the series, it helps newbies in reaching their goals in the career. All the best guys in learning c programming with coding compiler blog.

C Program To Reverse a String

Learn how to reverse a string in C programming. Reversing a string in C programming language can be done using various techniques, but here in this program, we used strrev() function to reverse a string.

C Program To Reverse a String without Using Function

C Program To Reverse a String Using Pointers

C Program To Reverse a Sting Using Recursion

C Program To Reverse a String Source Code

Copy paste the below source code or write your own logic into C compilers and run the program to see the result.

/* C PROGRAM TO REVERSE a STRING - REVERSESTRING.C */
#include <stdio.h>
#include <string.h>
 
int main()
{
   char arr[100];
 
   printf("Enter a string to reverse\n");
   gets(arr); //This function will get a string from user
 
   strrev(arr); //This function will reverse a string
 
   printf("Reverse of entered string is \n%s\n",arr);
 
   return 0;
}

C Program To Reverse a String Output

After you compile and run the above program, your C compiler asks you to enter a string to reverse. After you enter a string, strrev() function will reverse the string and show output like below expected output.

Enter a string to reverse programming

programming

Reverse of entered string is

gnimmargorp

Read Other C Programming Tutorials:

C Program To Swap Two Numbers Using Two Variables

C Program To Swap Two Numbers Using Three Variables

C Program For Prime Numbers – Check  a Number is Prime or Not

 

Leave a Reply

Your email address will not be published. Required fields are marked *