How do you write a program in c to calculate age?

1 answer

Answer

1024473

2026-04-21 02:25

+ Follow

//program to find the age of given date of birth

#include <dos.h>

#include <stdio.h>

int main(void)

{

struct date d;

int bd,bm,by,day,m,y,cd,cm,cy;

clrscr();

getdate(&d);

printf("\t**WELCOME TO AGE FINDER PLACE\n");

printf("\t*\n\n");

cd=d.da_day;

cm=d.da_mon;

cy=d.da_year;

printf("Enter the birthe date : ");

scanf("d%d",&bd,&bm,&by);

{

if(cd<bd)

{

cm=cm-1;

cd=cd+30;

day=cd-bd;

}else

day=d.da_day-bd;

}

{

if(cm<bm)

{

cy=cy-1;

cm=cm+12;

m=cm-bm;

}else

m=d.da_mon-bm;

}

y=cy-by;

printf("your age is:-\n");

printf("year=%d\tmonth=%d\tday=%d\n",y,m,day);

getch();

}

//by DILKASH

from MANUU

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.