Program
code
#include
<stdio.h>
#include
<conio.h>
void
main()
{
long
int temp=0, number=0, reverse=0;
clrscr();
printf(“Please
input a whole number to get its reverse.\n”);
scanf(“%ld”,&number);
for
(temp=number;temp>0;temp=temp/10)
reverse=(reverse*10)+(temp%10);
printf(“The
reverse of %ld is %ld\n”, number, reverse);
getch();
}
Example
of output
Please
input a whole number to get its reverse.
6754
The
reverse of 6754 is 4576
No comments:
Post a Comment
Please write here, your opinion about this C program