Wednesday, 26 December 2012
Any base to Decimal conversion:
Do you like this story?
Program for Any base to Decimal conversion:
This program shows how to convert a number in any base(it can be 2, 7..)
to decimal number system.The user enters the number and its base and the program converts it to decimal system.
//any base to decimal converting ....
#include<stdio.h>
#include<conio.h>
void main()
{
long signed int inputnumber,inputbase,k,op,s,p;
clrscr();
printf("Enter the number and its base");
scanf("%ld%ld",&inputnumber,&inputbase);
op=0;
k=inputnumber;
p=1;
while(k!=0)
{
s=k%10;
k=k/10;
op=op+s*p;
p=p*inputbase;
}
printf("The number is %ld",op);
getch();
}
and the output is like:
This post was written by: Franklin Manuel
Franklin Manuel is a professional blogger, web designer and front end web developer. Follow him on Twitter
Subscribe to:
Post Comments (Atom)
0 Responses to “Any base to Decimal conversion:”
Post a Comment