Aishwarya said:
on a lighter note, are we "positive" /*
*/ that the input is an
unsigned integer to the base of 10 ?
Aishwarya...
Of course not; but I hesitate to provide complete, general
solutions to homework problems. /My/ aim was to provide the OP
with something he could understand and modify as necessary to
meet the requirements of his assignment - to provide help without
eliminating the need for effort from the student.
It's a difficult balance to achieve, sometimes. It's easy to
either say: "Do your own homework!" or to provide the complete
solution. I find it much more difficult (but enormously more
satisfying) to provide a rough solution framework that a student
can hack on.
The modifications necessary to handle signed ints aren't really
difficult; and if output radix is an issue, the OP forgot to
mention it; and will have to further (trivially) modify the code.
A loser will hand in my code and almost certainly be identified
as submitting someone else's work - or they'll recognize that the
solution is incomplete and disregard it altogether. A winner will
note the use of "unsigned", work to understand what I've done,
and puzzle out the necessary modifications - and thereby make the
resulting program a product of his own efforts.
I always hope for winners.
8^)