#include <stdio.h>
int convert(int n,int base)
{
int pos=1,result=0;
while(n!=0)
{
result=result+(n%base)*pos;
pos=pos*10;
n=n/base;
}
printf("Converted Value: %d",result);
}
int main()
{
int n,base;
printf("Please Enter the Decimal Number: ");
scanf("%d",&n);
printf("Please Enter The Base Number Which You Want to Convert: ");
scanf("%d",&base);
convert(n,base); ///function Call.
return 0;
}
Output
Please Enter the Decimal Number: 120
Please Enter The Base Number Which You Want to Convert: 8
Converted Value: 170
Add your comment