1. User will input binary.
2. The program will reverse the binary number in order to start from the last integer all the way to wherever the user finishes with the binary number.
3. It will then multiply to the power of 0, 1, 2... wherever the number 1 is present and so on until the last integer.
4. It then adds up all the numbers and print out as decimal.
Is there a way to create an unlimited size array in order to put it into the decimal.
#include<stdio.h>
int main()
{
int binary_number[20], decimal_number[/*I can't leave it blank because it needs an integer so I don't know what to put*/], input;
printf("Please enter a binary number: ");
for(input = 0; input<20; input++)
scanf("%d", &binary_number[input]);
/*Call out decimal_number function*/
}
I also have to create a function in order to call it out and print in the main function.

New Topic/Question
Reply



MultiQuote





|