From 7ebe4fa9186af11630d16ad3c070623f3810cfb6 Mon Sep 17 00:00:00 2001 From: HemanthKumar8251 <85030810+HemanthKumar8251@users.noreply.github.com> Date: Mon, 4 Oct 2021 20:48:54 +0530 Subject: [PATCH 1/3] Create HexaDecimal-Decimal.cpp --- C++/Program_24/HexaDecimal-Decimal.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 C++/Program_24/HexaDecimal-Decimal.cpp diff --git a/C++/Program_24/HexaDecimal-Decimal.cpp b/C++/Program_24/HexaDecimal-Decimal.cpp new file mode 100644 index 00000000..7a2f0a5e --- /dev/null +++ b/C++/Program_24/HexaDecimal-Decimal.cpp @@ -0,0 +1,25 @@ +#include +using namespace std; +int convert(string n){ + int sum=0,s; + int x=1; + s = n.size(); + for (int i = s-1; i >=0; i--) + { + if(n[i]>='0'&&n[i]<='9'){ + sum += x*(n[i]-'0'); + } + else if(n[i]>='A'&&n[i]<='F'){ + sum += x* (n[i]-'A'+ 10); + } + x *= 16; + } + return sum; +} +int main(){ + string n; + cin>>n; + int d=convert(n); + cout< Date: Mon, 4 Oct 2021 20:50:40 +0530 Subject: [PATCH 2/3] Add files via upload --- C++/Program_24/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 C++/Program_24/README.md diff --git a/C++/Program_24/README.md b/C++/Program_24/README.md new file mode 100644 index 00000000..0034d8d1 --- /dev/null +++ b/C++/Program_24/README.md @@ -0,0 +1 @@ +Program to convert HexaDecimal number to Decimal Number. \ No newline at end of file From 2a2606295b40475f3fe7bbe6650975fbf5999b88 Mon Sep 17 00:00:00 2001 From: HemanthKumar8251 <85030810+HemanthKumar8251@users.noreply.github.com> Date: Mon, 4 Oct 2021 21:07:29 +0530 Subject: [PATCH 3/3] Update README.md --- C++/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/C++/README.md b/C++/README.md index c1e467b8..922575d5 100644 --- a/C++/README.md +++ b/C++/README.md @@ -13,3 +13,4 @@ | Program-10 | Program to find the missing number in a Sorted Array. | Program-15 | Program to find modular exponentiation. | Program-19| To check whether a number is in palindrome or not +| Program-24 | Program to convert Hexa-Decimal number to Decimal number