C/C++ code#include
#include
int main(void)
{
char binaryNum[100]; /**
* You can not represent a binary number directly in C.
* so i use a character array to store it. See...Anyway
* we just focus on the result, no matter what method
* is considered. :-)
*/
char *p = binaryNum;
double decimalNum = 0;
int n = 0, dotsNum = 0, i = 0, j = 0;
printf("Please type in a binary number:\n");
scanf("%s", &binaryNum);
/**
* CHECK IF THE ENTERED BINARY NUMBER IS LEGAL.
* I USED POINTERS. I TREAT THIS DECIMAL AS TWO
* PARTS: INTEGER & DECIMAL.
*/
for ( ; *p != '\0'; p++, n++) {
if (! (*p == '0' || *p == '1' || *p == '.')) { </