Im meant to Write a program that asks the user to enter the base of a numbering system. I ran into some errors help???
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
string x, base, bin;
int y;
int answer;
int final=0;
int p=0; // to keep track of exponential
cout << "enter the binary code: ";
cin >> bin;
for(int i=0; i=x.size(); i++){
y= x[i];
base = 2 ^ p;
answer= y * base;
p++;
final += answer;
}
return 0;
}
|
Last edited on
Sour about not paying attention in class.
Not at all..
Last edited on
I would change binary to an array of 8 bools. Since bool can only be either 1 or 0, it's perfect for binary digit representation.
Try reading this: http://www.wikihow.com/Convert-from-Decimal-to-Binary . Try using the same page to convert from binary to decimal.
Wazzak