Created the base_10_to_2.cpp

This commit is contained in:
Mathias Wagner 2023-11-11 14:08:19 +01:00
parent 958d24ec07
commit 67f687dbd2
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

22
base_10_to_2.cpp Normal file
View 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);
}