Hey guys, I'm having some trouble figuring out how to do a step in my program. My program is to convert binary numbers to interger values. Everything looks like it will work to me if I am able to add one more step. I have done calculations manually and it seems to work but I do not know how to take the first number out of the binary string then the second, third, etc. here is my program:
#include <stdlib.h>
#include <stdio.h>
int main ()
{
//prompt user for binary #
char binaryNumber;
printf("Please enter a binary number\n");
scanf("%c",&binaryNumber);
/*assign variable decimalValue 0*/
int decimalValue=0;
/*obtain variable nextDigit
(the first digit in the binary number, then the next and so on.)*/
here is where the problem is
while (nextDigit == (1||0))
{
/*assign variable decimalValue
the value of (decimalValue*2)+nextDigit*/
decimalValue = ((decimalValue*2) + nextDigit);
}
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.