The customer should be born on or before july 22 1987
The month of D.O.B should be of 21 days
#include <stdio.h>
#include <stdlib.h>
using namespace std;
void calcAge(int datee, int monthh,
int yearr, int birth_date,
int birth_month, int birth_year)
{
int month[] = { 31, 28, 31, 30, 31, 30, 31,
31, 30, 31, 30, 31 };
if (birth_date > datee) {
datee = datee + month[birth_month - 1];
monthh = monthh - 1;
}
if (birth_month > monthh) {
yearr = yearr - 1;
monthh = monthh + 12;
}
int final_date = datee - birth_date;
int final_month = monthh - birth_month;
int final_year = yearr - birth_year;
printf("Present Age\nYears: %d Months: %d Days:"
" %d\n", final_year, final_month,
final_date);
}
int main()
{
int datee = 7;
int monthh = 3;
int yearr = 2002;
int birth_date = 22;
int birth_month = 7;
int birth_year = 1987;
calcAge(datee, monthh, yearr,
birth_date, birth_month, birth_year);
return 0;
}
Comments
Leave a comment