Programming Examples

C program to Reverse a Sentence Using Recursion


Write a C program to Reverse a Sentence Using Recursion

Solution

#include <stdio.h>
void reverseSentence();
int main() 
{
    printf("Enter a sentence: ");
    reverseSentence();
    return 0;
}

void reverseSentence() 
{
    char c;
    scanf("%c", &c);
    if (c != '\n') {
        reverseSentence();
        printf("%c", c);
    }
}
Output

Enter a sentence: margorp emosewa

awesome program

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad