Contains the source code from the course work throughout my undergraduate Computer Engineering degree at Brigham Young University. There is a mixture of Go, Python, C, C++, Java, VHDL, Verilog, Matlab, Bash, Assembly, etc..
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.1KB

  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int main() {
  5. int value;
  6. int first, second, third, fourth, fifth;
  7. vector<int> final;
  8. cout << "please insert your number between 0 and 31" << endl;
  9. cin >> value;
  10. int prin = value%2;
  11. value = value/2;
  12. if(prin >=1)
  13. first = 1;
  14. else
  15. first = 0;
  16. final.push_back(first);
  17. prin = value%2;
  18. value = value/2;
  19. if(prin >=1)
  20. second = 1;
  21. else
  22. second = 0;
  23. final.push_back(second);
  24. prin = value%2;
  25. value = value/2;
  26. if(prin >= 1)
  27. third = 1;
  28. else
  29. third = 0;
  30. final.push_back(third);
  31. prin = value%2;
  32. value = value/2;
  33. if(prin >= 1)
  34. fourth = 1;
  35. else
  36. fourth = 0;
  37. final.push_back(fourth);
  38. prin = value%2;
  39. value = value/2;
  40. if(prin >= 1)
  41. fifth = 1;
  42. else
  43. fifth = 0;
  44. final.push_back(fifth);
  45. cout <<fifth<<fourth<<third<<second<<first << endl;
  46. // for(unsigned int i = 0 ; i<final.size();i++) {
  47. // cout << final[i];
  48. // }
  49. cout << "\n";
  50. }