C program to Reverse a Sentence Using Recursion

#include <stdio.h>
void reverse();
void main()
{
    printf("Please enter a sentence: ");
    reverse();
}
void reverse()
{
    char c;
    scanf("%c", &c);
    if (c != '\n') {
        reverse();
        printf("%c", c);
    }
}

Output:

Please Enter a sentence: awesome program
margorp emosewa
Sharing Is Caring

Leave a Comment