Pages

Write a program in c language to reverse a string using recursion.

Monday, 15 July 2013

#include<stdio.h>
#include <conio.h>
char* reverse(char[]); //function declaration

int main()
{

    char number[100],*rev;

    printf("Enter any string/number: ");
    scanf("%s",number);
    rev = reverse(number);
    printf("Reversed of given string/number is: %s",rev);
    getch();
}
//function definition.
char* reverse(char number[])
{

    static int i=0;
    static char rev[100];

    if(*number){
         reverse(number+1);
         rev[i++] = *number;
    }

    return rev;
}

 

Search Box

Most Reading

Contact Form

Name

Email *

Message *