C program to reverse a sentence entered by user using Recursion.

/* C program to reverse a sentence entered by user using Recursion. */

#include <stdio.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);
    }
}

Expected Output:
Enter a sentence: i am c programming
gnimmargorp c ma i

Post a Comment

Previous Post Next Post