Reverse a string using recursion in c ?
# include <stdio.h>
#include<conio.h>
void reverse(char *string)
{
if (*string)
{
reverse(string+1);
printf("%c", *string);
}
}
int main()
{
char array[] = "Asmit for Rahul";
reverse(array);
return 0;
}
Output:
timsA rof luhaR
 

 
 Hello, my name is Jack Sparrow. I'm a 50 year old self-employed Pirate from the Caribbean.
Hello, my name is Jack Sparrow. I'm a 50 year old self-employed Pirate from the Caribbean. 
No comments:
Post a Comment