Sunday, 11 December 2011

Write a program to print the reverse number in c

#include
#include
main()
{
char str1[10];
int i,len=0,j;
clrscr();
printf("Enter the string:");
gets(str1);
for(i=0;str1[i]!='\0';i++)
{
len++;
}
printf("\n The reverse string is:");
for(j=len-1;j>=0;j--)
{
printf("%c",str1[j]);
}
getch();
}

OUTPUT
Enter the string :MAHESH
The reverse string is : HSWHAM

No comments:

Post a Comment