Re: [Dev-C++] trying to write a program which determines an integer as palindrome or not
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: David M. <dml...@co...> - 2004-06-21 20:02:54
|
short get_digit(int number, short place)
{
return (number / pow(10,place)) % 10;
}
The above code can get you the digit at position x. I think you can
figure it out from there.
If you want all the digits one time you could use an array
//assume the number you want to test is in an int variable called num.
int digits[5];
for(int i = 0; i < 5; i++)
{
digits[i] = num % 10;
num = num / 10;
}
The rest is simple.
Is this homework?
dirty dragon wrote:
> hi everyone,
> trying to write a program which determines a 5 digit integer to be a
> palindrome or not.
> i'd like to use mudulus and division operands to separate parts of a 5
> digit integer.
> any suggestions?
>
> i posted this on the dev-users forum yesterday but i can't get into
> the forums today. anyone else having trouble?
>
> thanx pete
|