digit reverse in C

Newbie Member
30Apr2008,15:35   #1
soulemane's Avatar
All my greetings to everyone.
With a lot of respect to all members of this forum ,please i'm struggling since already many days to solve this problem.In fact how can we reverse a number (e.g 12345 to 54321)using only looping without array nor pointer or other advanced codes.Also for a number like 1000 it must be 1 inspites of 0001.
thank you for your support Assalam
Know what you can do.
6May2008,12:37   #2
SpOonWiZaRd's Avatar
Hello!!!!!!!!!!! I do not know that but I am sure pradeep will know.
Go4Expert Founder
6May2008,14:08   #3
shabbir's Avatar
Moved to C-C++ forum
TechCake
6May2008,14:30   #4
asadullah.ansari's Avatar
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