#include <iostream>
#include <math.h>
using namespace std;
int main(void)
{
char b[16];
cout << "Please input a binary number up to 16 digits...\n\n";
cin >> b;
int sum = 0, i=0;
while (i<16 && b[i] != (char)0) {
if (b[i] == '1') sum++;
else if (b[i] == '0') ;
else cout << " you are not inputting a binary number! \n";
i++;
}
cout << sum;
char c; cin >> c;
return 0;
}
*** MOD EDIT: Fixed code tags. Please
This post has been edited by JackOfAllTrades: 03 September 2009 - 04:29 AM

New Topic/Question
Reply




MultiQuote




|