Hello, I'm new to C++. A few years ago I took a C programming course, so I feel shaky with both. Today my question is related to an age in days and age in months program I'm writing. I can get the total year and months, but I'm having a hard time figuring out how to find the days. In this particular case I do not have to worry about leap year. And, Feb always =28.
This is the bit I have for months that works:
total_yr = today_yr - dob_yr;
total_mo = total_yr * 12;
if (dob_mo > today_mo)
{
new_dob_mo = dob_mo - today_mo;
total_mo_count = total_mo - new_dob_mo;
}
but my extension of this for days is not complete and I cannot see how to figure out the days part....
if (dob_mo > month)
{
total_yr = (year - dob_yr);
extra = dob_mo - month;
total_mo = (total_yr * 12) - extra;
if (day != dob_day) && (day < dob_day)
{
total_day = today;
}
if (day != dob_day) && (day > dob_day)
total_day =
}
else
{
extra = month - dob_mo;
total_yr = (year - dob_yr);
total_mo = (total_yr * 12) + extra;
total_day =
}
Any help in what to look for would be greatly appriciated!
This is the bit I have for months that works:
total_yr = today_yr - dob_yr;
total_mo = total_yr * 12;
if (dob_mo > today_mo)
{
new_dob_mo = dob_mo - today_mo;
total_mo_count = total_mo - new_dob_mo;
}
but my extension of this for days is not complete and I cannot see how to figure out the days part....
if (dob_mo > month)
{
total_yr = (year - dob_yr);
extra = dob_mo - month;
total_mo = (total_yr * 12) - extra;
if (day != dob_day) && (day < dob_day)
{
total_day = today;
}
if (day != dob_day) && (day > dob_day)
total_day =
}
else
{
extra = month - dob_mo;
total_yr = (year - dob_yr);
total_mo = (total_yr * 12) + extra;
total_day =
}
Any help in what to look for would be greatly appriciated!
Comment