Write a C program that uses a function to reverse a given string.

Program Code:
To reverse a given string using recursion
1. Start
2. Read a sentence
3. Use strrev() function to reverse a sentence
4. Display the reversed sentence
5. Stop

To reverse a given sentence by using recursion
#include<stdio.h>
#include<string.h>
void Reverse();
int main()
{
printf("Enter a sentence: ");
Reverse();
return 0;
}
void Reverse()
{
char c;
scanf("%c",&c);
if( c != '\n')
{
Reverse();
printf("%c",c);
}
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: