Question: The following program allows the user to convert decimal numbers to binary and binary to decimal numbers. Using the program below, write a multi-module program.

The following program allows the user to convert decimal numbers to binary and binary to decimal numbers. Using the program below, write a multi-module program.

mainDriver.c will contain the main()function

binToDec.c will contain the btod() function

decToBin.c will contain the dtob() function

defs.h will be the header file. It should contain the #include statements needed for the program, along with any prototypes

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #include #include #include #include // int dtob // int dtob(int inputDec,int a[]) { int counts = 0,num = inputDec; while(num!=0) { counts++; num=num/2; } int i; for(i=counts-1; i>= 0;i--) { a[i] = inputDec%2; inputDec = inputDec/2; } return counts; } int btod(char a[],int size) { int i,num=0; for(i = 0; ireturn num; } //convert decimal to binary// int main(){ int a[10000],n,i; printf("Enter a decimal number to convert to binary: "); scanf("%d",&n); int counts = dtob(n,a); printf(" The binary of the given number is "); for(i = 0; i < counts; i++) { printf("%d",a[i]); } //convert binary to decimal // printf(" Enter a binary number to convert to decimal: "); char c[100]; scanf("%s",&c); printf(" The decimal of the given number is %d ",btod(c,strlen(c))); //return 0// return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!