My instructor assigned my group to make a simple program to convert any binary into its one's complement by using arrays. I know how to do the one's complement; however, I do not have any idea as to what to do or what arrays are. One issue is that the instructor doesn't make sense or when he does, he mumbles so I can't hear anyways.
He gave a piece of starting code but I haven't gotten far. I tried using char instead of strings but that didn't get me anywhere. Any help would greatly be appreciated.
Code:/* Assignment Develop a function that will perform one's complement of a given binary number stored in an array bin. */ #include <iostream> #include <string> using namespace std; void OnesComp(string & BIN) { BIN[0]; return; } int main () { string BIN; cout << "Type in a binary number" << endl; cin >> BIN; //Code for conversion cout << "The binary number is: " << BIN << endl; OnesComp(BIN); cout << "The one's complement is: " << BIN << endl; cin >> BIN; return 0; }



LinkBack URL
About LinkBacks


