Monday 9 September 2013

c program to reverse a string without using pre-defined functions

#include<stdio.h>
 #include<conio.h>
 void main()
 {
char s[20],r[20];
int m,i,j=0;
clrscr();
printf("enter a string..");
gets(s);
for(m=0;s[m]!='\0';m++);
printf("\nlength of your string is:%d\n",m);
for(i=m;i+1!=0;i--)
{
r[j++]=s[i];
}
for(j=0;j<=m;j++)
{
printf("%c",r[j]);
}
getch();
}

No comments:

Post a Comment