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
0 Comments