Saturday, 14 March 2015

Program for reversing an integer Using C

# 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() ;
}


RUN 1 :
~~~~~~~
Enter a number : 2468
The Reversed Numeral is : 8642

No comments:

Post a Comment