|
#include < stdio.h > #include < conio.h > void main() { long n,dec,mult,r,base; clrscr(); printf("\n Enter a base : "); scanf("%ld",&base); printf("\n Enter a number :"); scanf("%ld",&n); dec = 0; mult=1; printf("\n Decimal equivalent of base %ld number %ld is ",base,n); while ( n != 0 ) { r = n % 10; n /= 10; r = r * mult; dec = dec + r; mult *= base; } // while printf("%ld",dec); }