C program to reverse a string is a program to reverse the given string using string function in c.

String in c
String in c is a collection of characters. And it ends with the null character.
In c string has different string functions such as strcmp, strrev, strlen etc.

String reverse in c
To find the reverse of the string in c the string class provided one function strrev() using this function we can find the reverse of the string.
Syntax for strrev in c
strrev function in c
strrev(string);
This function reverse given string.

Strrev example in c :-
strrev (“technical”);
The reverse of string is lacinhcet.

Algorithm to string reverse in c

  1. Declare variable. str, rev
  2. Take a string input from the user. str
  3. Find reverse of the string using a string function
    rev= strrev(string);
  4. Print the reversed string

C program to reverse a string

#include<stdio.h>
#include<string.h>
main()
{
char str[100];
printf("Enter a string to get reverse of string\n");
gets(str);
printf("The reverse of the given string is---> %s\n",strrev(str));
}

Output :

C program to reverse a string

Write A Comment