The BOTTOM LINE Quote Of The Day

The BOTTOM LINE Quote Of The Day

Don't Ever Tell GOD How BIG Your Problems are.
Just Tell Your Problems How BIG your GOD is ;)

Thursday, May 31, 2012

Finding the Equivalent Number at the Given Base


#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
  int i,b,e,tmp,nod=0;
  scanf("%d %d",&b,&e);
  tmp = b;
  while(tmp)
  {
    nod++;      
    tmp = tmp/e;          
  }
  printf("\n");
  while(nod>0)
  {  
   nod--;  
   tmp = 1;      
   for(i=0;i<nod;i++)
    tmp *= e;
   if(e != 16)
    printf("%d",b/tmp);
   else
   printf("%X",b/tmp);
 
   b %= tmp;      
  }
  getch();
  return 0;
}

No comments:

Post a Comment