The variables dec and mult are first initialzed to values 0 and 1 respectively. Then the variable n is divided by 10 and saves the remainder in variable r.The quotient is saved in variable n. The remainder r is multiplied by variable mult and then it added to variable dec.The variable mult is incremented by multiplying it by variable base.This process continous until the varible n is greater than 0.When the variable n decrements to 0 ,the decimal equivalent is stored in variable dec.

#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); } // main