Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions C/Program-49/README.md
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions C/Program-49/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <stdio.h>

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;
}