main()
{
struct date d;
int dat,mon,year,dob_day,dob_month,dob_year,age_day,age_month,age_year;
getdate(&d);
dat=d.da_day; \\getting current date from the system
mon=d.da_mon; \\getting current month from the system
year=d.da_year; \\getting current year from the system
printf("If you give invalid date it'll give wrong result:\n");
printf("enter date of birth:\nday:(dd)");
scanf("%d",&dob_day);
printf("\nmonth (mm):");
scanf("%d",&dob_month);
printf("\nyear (yyyy)");
scanf("%d",&dob_year);
if(dat<dob_day)
{
dat=dat+30;
mon=mon-1;
}
if(mon<dob_month)
{
mon=mon+12;
year=year-1;
}
age_day=dat-dob_day; \\Calculating AGE
age_month=mon-dob_month;
age_year=year-dob_year;
printf("your current age is:\n%d years %d months %d days",age_year,age_month,age_day);
getch();
}
Frenzz try this calculate age................the two header files to be included before execution are
stdio.h and dos.h
dat=dat+30;
mon=mon-1;
}
if(mon<dob_month)
mon=mon+12;
year=year-1;
}
age_day=dat-dob_day; \\Calculating AGE
age_month=mon-dob_month;
age_year=year-dob_year;
printf("your current age is:\n%d years %d months %d days",age_year,age_month,age_day);
getch();
}
Frenzz try this calculate age................the two header files to be included before execution are
0 comments:
Post a Comment