Saturday, 10 December 2011

Write a program to print the reverse number in c

#include
#include
main()
{
long int num,i;
int dig;
clrscr();
printf("\n Enter the number:-");
scanf("%ld",&num);
printf("\n The reverse of number %ld is:-",num);
for(i=num;i>0;i=i/10)
{
dig=i%10;
printf("%d",dig);
}
getch();
}

OUTPUT
Enter the number: 1 2 3 4 5
The reverse of number 1 2 3 4 5 is: 5 4 3 2 1

No comments:

Post a Comment