-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathH_4.cpp
More file actions
35 lines (26 loc) · 845 Bytes
/
H_4.cpp
File metadata and controls
35 lines (26 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//The modulo operator, %, returns the remainder of a division. For example, 4 % 3 = 1 and 12 % 10 = 2. The ordinary division operator, /, returns a truncated integer value when performed on integers. For example, 5 / 3 = 1. To get the last digit of a number in base 10, use 10 as the modulo divisor.
//Task
//Given a five digit integer, print the sum of its digits.
//Input Format
//The input contains a single five digit number, .
//Constraints
//10000<=n<=99999
//Output Format
//Print the sum of the digits of the five digit number.
//Sample Input 0
//10564
//Sample Output 0
//16
#include <stdio.h>
int main() {
int n,sum;
printf("Enter the no:\n");
scanf("%d",&n);
if(n>9999 && n>100000)
while(n>0){
sum+=n%10;
n/=10;
}
printf("sum:%d\n",sum);
return 0;
}