forked from MadhavBahl/OOPS
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDOB.c
31 lines (28 loc) · 735 Bytes
/
DOB.c
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
/* ======================================== */
/* ===== Input the DOB in DDMMYYYY, find n,
n is equal to the sum of digits
until the sum is single digit ===== */
/* ======================================== */
#include<stdio.h>
int findSum(int temp) {
int rem,sum=0;
while(temp > 0) {
rem = temp%10;
sum += rem;
temp /= 10;
}
if(sum<10)
return sum;
else
return findSum(sum);
}
int main() {
int sum,num,splNum;
printf("Enter the DOB(in DDMMYYYY): ");
scanf("%d",&num);
if(num<1000000) {
return printf("INVALID INPUT!!!!!\nEnter the DOB in DDMMYYYY");
}
splNum = findSum(num);
printf("The special number is: %d",splNum);
}