From 67f687dbd2297944f9102a6d2056d3b8c43d66eb Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sat, 11 Nov 2023 14:08:19 +0100 Subject: [PATCH] Created the base_10_to_2.cpp --- base_10_to_2.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 base_10_to_2.cpp diff --git a/base_10_to_2.cpp b/base_10_to_2.cpp new file mode 100644 index 0000000..347d5a9 --- /dev/null +++ b/base_10_to_2.cpp @@ -0,0 +1,22 @@ +#include + +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); +} \ No newline at end of file