If we enter the number upto four digit,answer is rite, Suppose I enter 1234 Answer is 4321.
But If we enter five digit numb,suppose 12345, Answer is not coming 54321.
If we declare num as long, even then the o/p is not coming out to be correct for 5 digit number.
When I enter 12345, answer is -11215.
When I enter the numb upto 4 digit, answer is coming correct.
The ints on your system are two bytes wide so they can only store numbers in
the range [-2^15,2^15-1], e.g. the number 54321 - 2^15 == -11215, so your
algorithm is correct, the ints are just to narrow (try four byte longs).
then wat to do to get the correct answer of Five digit number,,,,,,,Even if I declare the numb as long datatype.........even then the answer is not coming out to be correct
then wat to do to get the correct answer of Five digit number,,,,,,,Even if I declare the numb as long datatype.........even then the answer is not coming out to be correct
Make all your variable long ints and print them as such: %ld instead of %d.
Dear Sonia.;
ur code is absolutely correct. firstly check ur compiler size n gv 3/4 digit num.
as it is working in my sys. i.e visual studio..
ck it out n info.