Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Minwoo Ju

@Minwoo Ju
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • how do I improve: The number to binary code C++
    M Minwoo Ju

    #include
    #include
    using namespace std;

    void line() { cout << setw(12) << setfill('-') << endl;}

    int main() {

    int binary[8];
    int num;
    int bits[8] = {128,64,32,16,8,4,2,1};

    do {

    line();
    cout << "write in the number to be converted into binary." << endl;
    cin >> num;

    for(int i = 0;i < 8;i++) {

    if(num >= bits[i]){

    binary[i] = true;
    num = num - bits[i];

    }

    else if(num < bits[i]) {

    binary[i] = false;
    }

    }

    for(int i = 0;i < 8;i++) {

    cout << binary[i] ;

    }
    }while (1);

    system("pause");
    return 0;
    }

    this code is made about 1 month ago,and this is supposed to convert numbers into binary. Since I'm a beginner,the code might be messy and unintelligent. Please tell me how to improve this or to make it more efficient. If by any chance I'm in the wrong section, forgive me,this is the first time visiting this site.

    Clever Code c++ tutorial question code-review learning
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups