PROGRAM FOR REVERSE THE NUMBER

//program to reverse the number
#include<iostream.h>
#include<conio.h>
int ten(int j)
{
  int k=1,l;
  for(l=0;l<j;l++)
  {
     k=k*10;
  }
  return k;
}
void main()
{
  int n,i,count=0,c,r,rev=0,z;
  clrscr();
  cout<<"enter number:";
  cin>>n;
  c=n;
  while(n>10)
  {
     count++;
     n=n/10;
  }
  z=count;
  for(i=0;i<=count;i++)
  {
     r=c%10;
     rev+=(ten(z)*r);
     c=c/10;
     z--;
  }
  cout<<"\n"<<"reversed number="<<rev;
  getch();
}

Comments

Popular Posts