Here i am just giving you an idea. Solve it by making it efficient and accurate.

Code:
int nDigit=1,result=0;
while(n>0)
{
  n=n/10;
  ++nDigit;
}
for(int i=0; i<nDigit;++i)
{
   result = result+ n%10 +pow(10 , nDigit-i);
   n = n/10;
}

Last edited by shabbir; 6May2008 at 17:48.. Reason: Code block