1. ## Integer manipulation

HI ALL,
Just got bored and decided to look into a few things.
Like, is there a easy way to reverse an integer and assign that value to another int type?

Code:
```Example:
#include <stdio.h>
main(){
int grab;
int reverse;
printf("\"Enter a five digit integer\"\n");
scanf("%d", grab);
if ((grab > 00000)  && (grab <=99999)){
printf("\"You have entered: %d, great!\"\n");
}
else{
printf("\"To big a number!\"\n", grab);
}
//reverse integer and assign it into reverse
getche();
}

__________________________
Believing no rights are wrong, can be wrong by rights!
AmpIII```
Here is a quick example of what I was thunkin! Thanks for the help IA!

2. One way to reverse the digits of a number would be to count the digits in the number (1), then take each digit from the old number and put it into the right place in the new (2).

1. Counting the digits in a number.
Code:
`for(temp = number; temp; temp /= 10, digits ++);`
2a. Extracting a digit.
Code:
`digit = number / pow(10, num) % 10;`
2b. Assigning a digit.
Code:
`newnumber = newnumber + digit * pow(10, newnum);`

3. This should reverse an integer:
Code:
```int reverse(int get){
int temp=0,x;
for(x=get;x!=0;x/=10){
temp*=10;
temp+=x%10;
}
return temp;
}```

4. This has been asked before, quite recently.
Try a board search.

5. Oh, and this checks for overflow, if the number would be too big, it just outputs the highest (or lowest) possible value:
Code:
```int reverse(int get){
int temp=0,x;
__int64 check=0;
for(x=get;x!=0;x/=10){
check*=10;
check+=x%10;
if(check>std::numeric_limits<int>::max() && get>0){
return std::numeric_limits<int>::max();
}
else if(check*-1<std::numeric_limits<int>::min() && get<0){
return std::numeric_limits<int>::min();
}
else{
temp*=10;
temp+=x%10;
}
}
return temp;
}```

6. You could always mention that __int64 is non-standard.

7. ## Thanks!

Thanks for the comments to all who replied!

_______________________
Believeing no rights are wrong, can be wrong by rights!
AmpIII

8. And std:: things don't work in C... sorry