Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- { bool CarryOn = true;
- string ContOrNo;
- while(CarryOn == true)
- {
- cout << "Please input a decimal number without symbols or spaces" << endl;
- int DecimalNumber = 0;
- cin >> DecimalNumber;
- vector<int> BinaryResultVector;
- while (DecimalNumber > 0)
- {
- BinaryResultVector.push_back(DecimalNumber % 2);
- if(DecimalNumber % 2 == 1)
- {
- DecimalNumber = DecimalNumber--;
- }
- DecimalNumber = DecimalNumber / 2;
- }
- for(int i = BinaryResultVector.size()-1; i >= 0; i--)
- {
- cout << BinaryResultVector[i];
- }
- cout << "." << endl;
- cout << "do you want to continue? Key in any key if so, n if not" << endl;
- cin >> ContOrNo;
- if(ContOrNo == "n" || ContOrNo == "no")
- {
- CarryOn = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement