Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Contemporary Issues In Database Design And Information Systems Development

Authors: Keng Siau

1st Edition

1599042894, 978-1599042893

More Books

Students also viewed these Databases questions