Hello, Another exercise. In this particular problem we are given a five digit integer and program have to determine if its a Palindrome. Author states that we have to separate each digit into its own variables using % and /. I came up with solution but i don't know if its acceptable. It produces correct result but it looks bad to me. Here's my code, can someone look over it and give me any suggestions what i should have done instead or how i can improve it. Also author only had five digit numbers as examples. Thanks.
//deitel chaper palindrome
#include "stdafx.h"
#include <iostream>
using namespace std;
int main(){
int iCouner, iNumOne = 0, iNumTwo = 0, iWhole,
iRemainder, iNumThree =0, iNumFour = 0,
iNumFive = 0, iRev = 0;
iWhole = 12321;
for( iCouner = 10000; iCouner >= 1; iCouner /= 10){
iRemainder = iWhole % iCouner;
if ( ( iWhole / 10 ) > 0 ) {
iWhole /= iCouner;
}
//each variable to contain just a whole number
if ( iRev == 0 )
iNumOne = iWhole;
else if ( iRev == 1 )
iNumTwo = iWhole;
else if ( iRev == 2)
iNumThree = iWhole;
else if ( iRev == 3 )
iNumFour = iWhole;
else
iNumFive = iWhole;
iWhole = iRemainder;
++iRev;
}
if ( iNumOne == iNumFive && iNumTwo == iNumFour )
cout << "its a palindrome" << endl;
else
cout << "Its not a pslindrome" << endl;
return 0;
}