decimal to binary converter c++? -


int inputnumber=0; int divisionstore=0,modstore=0; vector<int> mainvector;  cout << "\nenter number convert binary.\n" << endl;  cin >> inputnumber;  {     modstore=inputnumber%2;     inputnumber=inputnumber/2;     mainvector.push_back(modstore);  }while(inputnumber!=1);  (int i=0;i<mainvector.size();i++) {     cout<<endl<<mainvector[i]<<endl; } 

seems there logical error cant find whats wrong it? program not print correct conversion seems loop ends before can push last number.

i think need change:

}while(inputnumber!=1) 

to:

}while(inputnumber!=0) 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -