Created the base_10_to_2.cpp
This commit is contained in:
parent
958d24ec07
commit
67f687dbd2
22
base_10_to_2.cpp
Normal file
22
base_10_to_2.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
|
||||||
|
int base10 = 25;
|
||||||
|
|
||||||
|
cout << "Gib deine Base10 Zahl ein: ";
|
||||||
|
cin >> base10;
|
||||||
|
int base10val = base10;
|
||||||
|
|
||||||
|
string binary;
|
||||||
|
while (base10 != 0) {
|
||||||
|
binary = (base10 % 2 == 0 ? "0" : "1") + binary;
|
||||||
|
base10 /= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << base10val << " in binär ist " << binary;
|
||||||
|
|
||||||
|
return (36 & 8);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user