Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am having trouble with trying to figure this code out. I have posted the assig

ID: 3596805 • Letter: I

Question

I am having trouble with trying to figure this code out. I have posted the assignement. It is a code that is supposed to convert Binary to Decimal. Only using a integer array. I have also posted what I have already done which is most likely wrong. I am lost, please help me.Thank you!

tbreckenridge-ssh tbrecke@access.cs.clemson.edu-99x66 File Edit Options Buffers Tools C Help #include #include int main(void) int binary int numofDigits; to 10 digits: ) printf("Enter a binary number of up scanf("%d",&binary;) ; nunOfDigits (log 10(binary)) + 1; int array[numOfDigits] int i = nunOfDigits-1; while (binary 8) int array = binary % 10; binary-10; array[1] = array; i--i printf("The binary number you entered was: %d ", *array); return 0; (C/l Abbrev)

Explanation / Answer

Answer:-

this is very optimized way to find the Decinal of given binary

#include <stdio.h>
int main(void)
{
char binary; int decimal = 0;
int count=0;
printf("Enter the binary digits upto 10 digits ");
while (binary != ' ')
{
if(count>10)
{
printf("You are entered more than 10 digits of Binary ");
return 0;
}
scanf("%c",&binary);
if (binary == '1') decimal = decimal * 2 + 1;
else if (binary == '0') decimal *= 2;
count++;
}
printf("%d ", decimal);
return 0;

}