Problems reversing large int

Joined
Mar 29, 2007
Messages
5
Reaction score
0
im trying to reverse a large int.getting a problem with the pow function.
Say i try to reverse 234 im getting 431..
here is the code im using


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
main(){
int i,number, tnum, index, reverse = 0;
printf("Please enter an integer: ");
scanf("%d", &number);
index = log10(number);


for (i = index; i>=0; i--)
{
tnum = number % 10;
reverse += tnum * pow(10,i);
number = number / 10;
}
printf("%d\n",reverse);

system("pause");
}


thanks in advance
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top