C program to print the reverse of the string

This program implements the function strrev() to print the reverse of the string. Firstly, the program will ask the user to enter any string. Then it uses the strrev() function by passing the string entered by the user as a parameter. The function will return the reverse of the string .

Before moving on to the example you need to make sure that you have good knowledge and understanding of the following topics.

Now, look at the codes below written in C to learn about its implementation details.

Code:

#include<stdio.h>
#include<string.h>
int main()
{
	char s1[50];
	puts("Enter a string: ");
	gets(s1);
	strrev(s1);
	printf("The output after doing the reverse of the string entered is: %s", s1);
}

The above code will display its output as below.

Output:

Enter a string:
program
The output after doing the reverse of the string entered is: margorp
SHARE C program to print the reverse of the string

You may also like...

Leave a Reply

Your email address will not be published.

Share