From 4ab7e715ef0ebdcc3d7af19fe885473ca3624fe5 Mon Sep 17 00:00:00 2001 From: neha030 Date: Tue, 25 May 2021 19:51:22 +0530 Subject: [PATCH 1/2] Sum Of Digits added --- Sum_of_digits.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Sum_of_digits.txt diff --git a/Sum_of_digits.txt b/Sum_of_digits.txt new file mode 100644 index 0000000..4e9ae4c --- /dev/null +++ b/Sum_of_digits.txt @@ -0,0 +1,15 @@ +#include +int main() +{ + int n,r,sum=0; + printf("Accept the number: "); + scanf("%d",&n); + while(n!=0) + { + r=n%10; + sum=sum+r; + n=n/10; + } + printf("Sum of number %d",sum); + return 0; +} \ No newline at end of file From 87fdd82d0ff707fab5f510f4e4168661f34ac401 Mon Sep 17 00:00:00 2001 From: neha030 Date: Sun, 30 May 2021 21:11:05 +0530 Subject: [PATCH 2/2] description added --- Sum_of_digits.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sum_of_digits.txt b/Sum_of_digits.txt index 4e9ae4c..f69ad6d 100644 --- a/Sum_of_digits.txt +++ b/Sum_of_digits.txt @@ -1,3 +1,10 @@ +/* Description of the code +This code provides the sum of digits of a given number. +eg:if the entered number is 234, the the sum of digits will be: +sum=2+3+4=9 +so the desired output will be 9. +*/ + #include int main() {