I started to program on C++ on converting 8bit binary to its decimal requested for my school project. But i have problem to proceed further as i am lost on what to add on next. Can someone help me to add on to my program to allow it to work.. ThX for your help.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
int main()
{
char binaryinput[8];
char binaryoutput[8];
char response;
int i;
int result = 0;
do
{
printf("\t4: 8-bit Binary to Decimal Conversion\n");//binarytodecimal function call
printf("\t=====================================\n\n");
printf("\tPlease enter an 8-bit binary bits:");
for(i=7; i<8; i--)
{
binaryinput[i] = getche();
}
for(i=0; i<8; i++)
{
if(binaryinput[0] == '1')
{
result = binaryinput[i] * pow(2,0);
}
else if(binaryinput[0] == '0')
{
}
printf("\n\tThe binary number %s has been converted to %d decimal\n\n",i ,result);
response = getch();
}
while (( response == 'y') || ( response == 'Y'));
system("pause");
return 0;
}