external_1.c
Source Code
c
#include<stdio.h>
int sum(int);
int product(int);
int main() {
int num;
printf("Enter a positive integer: ");
scanf("%d", &num);
printf("\nSum of the integer is %d", sum(num));
printf("\nProduct of the integer is %d", product(num));
return 0;
}
int sum(int num) {
int s = 0;
while (num != 0) {
s += num % 10;
num = num / 10;
}
return s;
}
int product(int num) {
int pro = 1;
while(num != 0) {
pro *= num % 10;
num /= 10;
}
return pro;
}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
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