Program for reversing an integer
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
long n, r, s = 0;
clrscr();
printf("Enter a number : ");
scanf("%ld", &n);
while(n > 0)
{
r = n % 10;
s = r + s * 10;
n = n / 10;
}
printf("\nThe reversed number is : %ld", s);
getch();
}
Output:
Enter a number : 2468
The Reversed Numeral is : 8642
-
UpdatedDec 30, 2019
-
Views6,712
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order