Skip to content

Commit a37b8cd

Browse files
committed
Create ageinsecs.c
Ehkso C age_calculator Submission
1 parent fc677ba commit a37b8cd

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

age_calculator/Ehkso/ageinsecs.c

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <math.h>
4+
5+
int main(void){
6+
double years = 0;
7+
double secs = 0; // U have no secs lol
8+
double bils=0,mils=0,thous=0;
9+
10+
printf("How old are you (in years)? \n"); // the tin
11+
scanf("%lf", &years);
12+
//printf("%lf", years); // Just checking
13+
secs = (years * 365.2425) * 86400; // A day has 86400, Gregorian calendar says 365.2425 days/year
14+
printf("That's ");
15+
if (secs >= 1000000000){
16+
bils = floor(secs / 1000000000);
17+
printf("%.0lf billion, ", bils);
18+
secs -= bils * 1000000000;
19+
}
20+
if (secs >= 1000000){
21+
mils = floor(secs / 1000000);
22+
printf("%.0lf million, ", mils);
23+
secs -= mils * 1000000;
24+
}
25+
if (secs >= 1000){
26+
thous = floor(secs / 1000);
27+
printf("%.0lf thousand, and ", thous);
28+
secs -= thous * 1000;
29+
}
30+
printf("%.0lf second(s). And counting.", secs);
31+
}

0 commit comments

Comments
 (0)