C Program to Reverse a Sentence using Recursion
ADVERTISEMENTS
C program to reverse a sentence using recursion. In this article, you will learn how to reverse a sentence using recursion in c language.
Source Code
// C Program to Reverse a Sentence using Recursion
#include <stdio.h>
void revParagraph();
// It's the driver function
int main() {
printf("-----Enter the sentence to make reverse-----\n");
revParagraph();
printf("\n");
return 0;
}
// This function will reverse the input string
void revParagraph() {
char x;
scanf("%c", &x);
if (x != '\n') {
revParagraph();
printf("%c", x);
}
}
Output
-----Enter the sentence to make reverse-----
testing program
margorp gnitset
testing program
margorp gnitset