From b3f9c2c3a7e4254980cdd339cb8477f962b7b319 Mon Sep 17 00:00:00 2001 From: Tanushree Aggarwal <47485195+shreetanu@users.noreply.github.com> Date: Sat, 3 Oct 2020 13:17:15 +0530 Subject: [PATCH 1/3] Program.cpp Program in C++ to find the sum of digits of a number. --- C++/Program-5/program.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 C++/Program-5/program.cpp diff --git a/C++/Program-5/program.cpp b/C++/Program-5/program.cpp new file mode 100644 index 00000000..7d1c929f --- /dev/null +++ b/C++/Program-5/program.cpp @@ -0,0 +1,18 @@ +#include +using namespace std; + +int main() { + cout<<"enter the number\n"; + int n; + cin>>n; + int temp, rem, sum = 0; + temp = n; + while(temp>0) + { + rem = temp%10; + temp = temp/10; + sum+=rem; + } + cout<<"\nThe sum is "< Date: Sat, 3 Oct 2020 13:20:01 +0530 Subject: [PATCH 2/3] Readme.md --- C++/Program-5/Readme.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 C++/Program-5/Readme.md diff --git a/C++/Program-5/Readme.md b/C++/Program-5/Readme.md new file mode 100644 index 00000000..0cdf10f8 --- /dev/null +++ b/C++/Program-5/Readme.md @@ -0,0 +1,13 @@ +Program 49 + +Write a program to find the sum of the digits of the given number. + +Variable description-- + +n=Number + +sum= Holds the sum + +rem=Holds the single digit of the number + +temp=Temporarily holds the value of n From 5033209bfdd2240d4be1b91c5c58ad4de0275888 Mon Sep 17 00:00:00 2001 From: Tanushree Aggarwal <47485195+shreetanu@users.noreply.github.com> Date: Sat, 3 Oct 2020 13:22:54 +0530 Subject: [PATCH 3/3] Update Readme.md --- C++/Program-5/Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C++/Program-5/Readme.md b/C++/Program-5/Readme.md index 0cdf10f8..4d9e8c08 100644 --- a/C++/Program-5/Readme.md +++ b/C++/Program-5/Readme.md @@ -1,4 +1,4 @@ -Program 49 +Program 5 Write a program to find the sum of the digits of the given number.