Facebook Google Plus YouTube

C program reverse a string using recursion.

Reverse a string using recursion.

Procedure:

#include<stdio.h>
#include <string.h>
void reverse(char *line)
{
    if(*line)
    reverse(line+1);
    printf("%c",*line);
}
int main()
{
char str[] ="Learn and share blog";
printf("The reverse string is :\t");
reverse(str);
return 0;
}

Output:

The reverse string is : golb erahs dna nraeL

Leave a Reply

%d bloggers like this: