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);
}
}
Post A Comment:
0 comments: