From 4572cfbbdbc3be2d7379a88ffd48f11781ab7782 Mon Sep 17 00:00:00 2001 From: jainvaidehi <54447956+jainvaidehi@users.noreply.github.com> Date: Thu, 1 Oct 2020 00:48:28 +0530 Subject: [PATCH 1/2] Created program --- C/Program-49/program.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 C/Program-49/program.c diff --git a/C/Program-49/program.c b/C/Program-49/program.c new file mode 100644 index 00000000..cc5d2743 --- /dev/null +++ b/C/Program-49/program.c @@ -0,0 +1,18 @@ +#include + +int main() { + + int n; + printf("Enter the number"); + int num; + scanf("%d",&num);//Enter the number + int sum=0,dig=0; + while(num>0) + { + dig=num%10; + sum+=dig; + num/=10; + } + printf("The sum of digits of a number is: %d",sum); + return 0; +} From 3f83d6e8c30d7ab1d3cf80b1cd1b2803f63d7dbc Mon Sep 17 00:00:00 2001 From: jainvaidehi <54447956+jainvaidehi@users.noreply.github.com> Date: Thu, 1 Oct 2020 00:51:21 +0530 Subject: [PATCH 2/2] Created README --- C/Program-49/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 C/Program-49/README.md diff --git a/C/Program-49/README.md b/C/Program-49/README.md new file mode 100644 index 00000000..7766aa7c --- /dev/null +++ b/C/Program-49/README.md @@ -0,0 +1,8 @@ +Program 49 + +Write a program to find the sum of the digits of the given number. + +Variable description-- +num=Number +sum= Holds the sum +dig=Holds the single digit of the number