c program to reverse string without using library functions
#include<stdio.h>
#include<string.h>
main()
{
char str[50],revstr[50];
int i=0,j=0,n=0;
printf("Enter the string to be reversed : ");
scanf("%s",str);
while(str[n]!='\0') //to get string length
{
n++;
}
for(i=n-1;i>=0;i--) //at 1st iteration i=total length-1
{
revstr[j]=str[i];
j++;
}
revstr[j]='\0';
printf("Input String : %s",str);
printf("\nOutput String : %s",revstr);
getch();
}
Ur program is absolutely ri8, bt fr 1 small error.. Variable "n" is nt declared.. :)
ReplyDelete