Question: Write in C please!! I will leave a like! The following C program is to convert numbers from binary to decimal: #include void main ()

Write in C please!! I will leave a like!

The following C program is to convert numbers from binary to decimal:

#include

void main () { char bin[80]; int i = 0, dec = 0; printf("Enter binary number: "); scanf("%s", bin); while (bin[i] != 0) { if (bin[i] == '0') dec = dec * 2; else if (bin[i] == '1') dec = dec * 2 + 1; else printf("Bad character %c in the number. ", bin[i]); i = i + 1; } printf("The decimal equivalent is %d ", dec);

}

The above program can be named like bin2dec.c and be compiled on smaug with "gcc bin2dec.c -o bin2dec.out".

Design and implement a C program to convert an arbitrary base b1 to another base b2, as specified by the user. Support bases up to 16, using the letters of the alphabet for digits greater than 9. The user should enter b1 and b2, and the number to convert in base b1. The program should print the equivalent number in base b2.

Your C program should be named b1_to_b2_your_lastname.c like b1_to_b2_lee.c

Submit your C file only

I will compile your file with gcc b1_to_b2_your_lastname.c -o a.out

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!