I am trying to formulate an age calculator, where in if you input your date of birth, it outputs your age in days.
Can anybody help me with some ideas or a simple programme ?.

many thanks
Indana
Moderator: Benj
Code: Select all
char age, month, day, input_month, input_day;
short year, input_year;
// year, month and day is given by a RTC (?)
// input_year, input_month and input_day is given by the user
age = year - input_year - 1;
if ((month - input_month) > 0) // if (month - input_month) is higher than 0
{
age = age + 1; // add 1 to age
}
else if (month == input_month) // if the given month is equal to the month given by the RTC
{
if ((day - input_day) >= 0) // and if (day - input_day) is higher or equal to 0
{
age = age + 1; // add 1 to age
}
}