Showing posts with label reverse. Show all posts
Showing posts with label reverse. Show all posts

Wednesday, May 16, 2018

C program to display the reverse of the given number.


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