#include <stdio.h> #include <stdlib.h> #include <math.h> /* Function Prototypes */ int bintodec(int fbase, int number); int main() { int number; int fbase; int tobase; int result; printf("Enter base from: "); scanf("%d",&fbase); printf("Enter your number:"); scanf("%d",&number); printf("Enter base to convert to: "); scanf("%d",&tobase); result = bintodec(fbase,number); printf("The result is:%d", result); system("PAUSE"); return 0; } int bintodec(int fbase, int number) { int bin[256]; int counter =0; int counterR =0; int quo =1; int result =0; int result1 =0; int res[256]; static int sum =0; while(quo>0) { quo= number/10; bin[counter] = number%10; number=quo; counter++; } while (counter>0) { result = pow(fbase, (counter-1)); result1=result*bin[counter-1]; res[counterR]=result1; counter--; counterR++; } while (counterR > 0) { sum = sum + res[counterR-1]; counterR--; } return sum; }

and here i also have decimal to binary:

#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int tobase=0; int number =0; int counter = 0; int bin [25]; int quo = 1; printf("Enter your number:"); scanf("%d",&number); printf("Enter base to convert to: "); scanf("%d",&tobase); while (quo!= 0) { quo= number/tobase; bin[counter] = number%tobase; counter ++; number=quo; } while (counter > 0) { printf( "%d", bin[counter-1]); counter --; } system("PAUSE"); return 0; }

i need to get those 2 separate codes into one source code which will ask the user to either convert from binary to decimal vice versa .....please help me out this is due a day from now

.....i think i was in the wrong forum ...my apologies