1. ## How to calc. your age in days..?

Does anybody have a good idea, to how the easiest way to
calc you age in days.

------------------------------------code until now.

int yearcalc_how_many_y, yearcalc_how_many_days;
int date, month, birthyear, age;

int calc_age_i_dage(int date, int month, int birthyear)
{
int currentyear = 2002;
printf("plz key you birthday<dd>: ");
scanf("%d", &date);
printf("Plz key in month <mm>: ");
scanf("%d", &month);
printf("plz key in birthyear <yyyy>: ");
scanf("%d", &birthyear);
age = date+month+birthyear;

yearcalc_how_many_y = (currentyear - birthyear);
printf("%d",yearcalc_how_many_y);
yearcalc_how_many_days = (yearcalc_how_many_y * 365)+((yearcalc_how_many_y/4)-1);
printf("%d",yearcalc_how_many_days);

return age;
}

int main()
{

struct date d;

getdate(&d);
printf("The current year is: %d\n", d.da_year);
printf("The current day is: %d\n", d.da_day);
printf("The current month is: %d\n", d.da_mon);

calc_age_i_dage(date, month, birthyear);

printf("Age: %d", age);

getch();
return 0;
}

/*
Which year is leap year.
<2000>-1996-1992-1988-1984-1980-1976-1972-1968-1964-1960-1956-1952-1948

Year 2000 didn't count, because, year which divides with 400 is not a leap year
*/

2. What kind of precision do you need? If it doesn't matter then just multiply the age in years by the number of days in a standard year.

-Prelude

3. imho, your program's flawed. scrap it, and think up a new one. try to limit your variables as much as possible

4. You can simplify this, as Prelude stated:

days_alive = (int)(365.25 * years_alive);

Actually, you could also use standard 'time' functions and do a bit of subtraction also...

Quzah.

5. yes prob, but is that precis enough, it's has to be 99% correct..

6. > yes prob, but is that precis enough, it's has to be 99% correct..

If it only hast to be 99% correct, you don't even have to bother
using .25 on the end. Hell, you can bee over 3 days off PER YEAR

Quzah.

7. >yes prob, but is that precis enough, it's has to be 99% correct..
99% correct in this context is way off and gives you a lot of breathing room.
Calculate the current number of days that have passed in the current year then just
totalDays = ( totalYears - 1 ) * 365 + currentDays;
and you'll still be very accurate without having to bother with leap year and all of that junk.

The hardest part will be counting the days that have passed in the current year, which should tell you how easy this can be.

-Prelude

8. My opinion is: if you do something, then do it right.
If the algorythm you're using is not 100% accurate, well, don't call it algorythm.