Reverse String Using Recursion in C Program Tamil


/*Reversing given string using recursion */
#include<stdio.h>
#include<conio.h>
#include<string.h>
char *rev(char [],char [],int,int);
void main()
{
	int n,i;
	char a[100],b[100];
	clrscr();
	printf("\nEnter the String :");
	scanf("%s",a);
	n=strlen(a);
	i=n-1;
	printf("\nReverse String : %s",rev(a,b,n,i));
	getch();
}
char *rev(char s1[100],char s2[100],int n,int i)
{
	s2[n-i-1]=s1[i];
	if(i>=0)
	{
	       return rev(s1,s2,n,i-1);
	}
	else
	{
		s2[n+1]='\0';
		return (s2);
	}
}

Login To Download Source Code

Leave a Comment:

Login To Comment

List Of Programs


Goto Examples

Operators

Looping

Number Conversion

Pattern Design

Arrays

Matrix Examples

Sorting Examples

String Function

Change Case

String In C

Maths Functions

User Defined Functions

Recursive Functions

Pointer

Structure

File Concept

Calender Programming