Question: Write a Ct+ program to input a binary number and convert it to a decimal number. Input the number in a character array, The Input
Write a Ct+ program to input a binary number and convert it to a decimal number. Input the number in a character array, The Input can only be In the form of 1s and 8s In order to convert a binary number to a decimal number, you have to multiply the right most binary digit with 2 (i.e. 1), the next binary digit with 21, the next with 2 and so on and then compute the sum of these numbers. For example: For input 111, the answer is: 1x21x2+1x21x4 1x2 + 1x1 -7 For input 100, the answer is: 1x22+ 0x2+0x2 1x4 0x2 +0x1 4 Note: you are not required to create any functions for this question er a binary number, (Is and 0) 1111 he equivalent decimal number is:15 rocess returned (0x0) execution time :4.883 ress any key to cont Inue. Enter a binary number (ds and e Il The equivalent decimal number is:3 rocess returned &(0x0) execution time 1.513
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
