-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculate_how_many_days_you_live.c
92 lines (56 loc) · 1.8 KB
/
calculate_how_many_days_you_live.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// main.c
// odevVize
//
// Created by ertuğrul gazi akça on 25.11.2017.
// Copyright © 2017 iosDev. All rights reserved.
//
#include <stdio.h>
int main() {
// insert code here...
int dayToday;
int monthToday;
int yearToday;
int dayBirthday;
int monthbBirthday;
int yearBirthday;
int dogum = 0 ;
int suan = 0;
int yasanilanGun = 0;
// dizi üzerinde ayları tanımladık.
int aylar[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
printf("Bugünün tarihini gün,ay,yıl şeklinde giriniz : ");
scanf("%d,%d,%d",&dayToday,&monthToday,&yearToday);
printf("Doğum tarihinizi gün,ay,yıl şeklinde giriniz : ");
scanf("%d,%d,%d",&dayBirthday,&monthbBirthday,&yearBirthday);
if (yearBirthday % 400 == 0) {
aylar[1] = 29;
} else if (yearBirthday % 100 == 0 ){
aylar[1] = 28;
}else if (yearBirthday % 4 == 0 ){
aylar[1] = 29;
}
dogum = ((yearBirthday-1)*365) + ((yearBirthday-1)/4);
dogum = dogum - (yearBirthday-1/100)+(yearBirthday-1/400);
for (int i=0; i < monthbBirthday-1; i++) {
dogum += aylar[i];
}
dogum += dayBirthday;
if (yearToday % 400 == 0) {
aylar[1] = 29;
} else if (yearToday % 100 == 0 ){
aylar[1] = 28;
}else if (yearToday % 4 == 0 ){
aylar[1] = 29;
}
suan = ((yearToday-1)*365) + ((yearToday-1)/4);
suan = suan - (yearToday-1/100)+(yearToday-1/400);
for (int i=0; i < monthToday-1; i++) {
suan += aylar[i];
}
suan += dayToday;
yasanilanGun = suan - dogum;
printf("%d gün yaşadınız.", yasanilanGun);
getchar();
return 0;
}