Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Input an integer number from the keyboard and print out the reverse of that number
SUBMITTED BY:
Guest
DATE:
Nov. 5, 2013, 5:45 p.m.
FORMAT:
C++
SIZE:
614 Bytes
Raw
Download
Tweet
HITS:
920
Go to comments
Report
// PURPOSE : Input an integer number from the keyboard and print out the reverse of that number
#include
<stdio.h>
int
main
()
{
int
n
;
int
backup_copy_of_n
;
int
digit
;
int
reverse
=
0
;
printf
(
"
\n
Please enter a positive integer : "
);
scanf_s
(
"%d"
,
&
n
);
backup_copy_of_n
=
n
;
while
(
n
!=
0
)
{
digit
=
n
%
10
;
reverse
=
(
reverse
*
10
)
+
digit
;
n
=
n
/
10
;
}
printf
(
"
\n
The reverse number for %d is %d."
,
backup_copy_of_n
,
reverse
);
getchar
();
getchar
();
return
0
;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus