Program to reverse the string using string functions
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main( )
{
char str[50],rev[50];
int i,n,j;
/*read the string */
printf("\nEnter the string : ");
gets(str);
/*find the length of the string */
n=strlen(str)-1;
i=n;
j=0;
while(i>=0)
{
rev[j]=str[i];
j++;
i--;
}
rev[j]='\0';
printf("\nReverse = %s",rev);
getch();
}
Example :
String : kapil
Reverse:lipak
Comments
Post a Comment