From bc85128a4c046b34aabd1843011c2854918411c3 Mon Sep 17 00:00:00 2001 From: Nehal Chaudhari <58935474+nehalchaudhari31@users.noreply.github.com> Date: Fri, 29 Oct 2021 11:02:04 +0530 Subject: [PATCH] =?UTF-8?q?Convert=20Binary=20to=20Decimal=C2=A0program=20?= =?UTF-8?q?in=20C++?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hactoberfest 2021 --- ...t Binary to Decimal\302\240program in C++" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "Convert Binary to Decimal\302\240program in C++" diff --git "a/Convert Binary to Decimal\302\240program in C++" "b/Convert Binary to Decimal\302\240program in C++" new file mode 100644 index 00000000..3e5c6393 --- /dev/null +++ "b/Convert Binary to Decimal\302\240program in C++" @@ -0,0 +1,34 @@ +#include +#include +using namespace std; + +int main() + +{ + + long int i, no; + + int x, y = 0; + + cout << "Enter any binary number: "; + + cin >> no; + + cout << "\nThe decimal conversion of " << no << " is "; + + for (i = 0; no != 0; i++) + + { + + x = no % 10; + + y = (x) *(pow(2, i)) + y; + + no = no / 10; + } + + cout << y; + + return 0; + +}