You can calculate your age by this coding. Or you can use this coding as a age calculator.
If you have any easier idea for his program, plz write i in comments.
Coding:
#include<stdio.h>
main()
{
int a,b,c,d,e,f;
int dd1,mm1,yy1;
int dd2,mm2,yy2;
int dd,mm,yy;
char azim[4];
do{printf("Enter birthday dd_mm_yy\t");
scanf("%d %d %d",&dd1,&mm1,&yy1);
printf("\nCurrent date dd_mm_yy\t");
scanf("%d %d %d",&dd2,&mm2,&yy2);
if(mm2>=mm1)
{if (dd2>=dd1){yy=yy2-yy1;mm=mm2-mm1;dd=dd2-dd1;}
else{yy=yy2-yy1;mm=mm2-mm1-1;dd=30+dd2-dd1;}}
else
{if(dd2>=dd1){yy=yy2-yy1-1;mm=12-(mm1-mm2);dd=dd2-dd1;}
else{yy=yy2-yy1-1;mm=11-(mm1-mm2);dd=30+dd2-dd1;}}
printf("\n%d yrs & %d months %d days old",yy,mm,dd);
printf("\n\ndo you want to repeat (y/n)? ");
getch(azim);
}
while(azim[0]!='n');
getch();
}
If you have any easier idea for his program, plz write i in comments.
Coding:
#include<stdio.h>
main()
{
int a,b,c,d,e,f;
int dd1,mm1,yy1;
int dd2,mm2,yy2;
int dd,mm,yy;
char azim[4];
do{printf("Enter birthday dd_mm_yy\t");
scanf("%d %d %d",&dd1,&mm1,&yy1);
printf("\nCurrent date dd_mm_yy\t");
scanf("%d %d %d",&dd2,&mm2,&yy2);
if(mm2>=mm1)
{if (dd2>=dd1){yy=yy2-yy1;mm=mm2-mm1;dd=dd2-dd1;}
else{yy=yy2-yy1;mm=mm2-mm1-1;dd=30+dd2-dd1;}}
else
{if(dd2>=dd1){yy=yy2-yy1-1;mm=12-(mm1-mm2);dd=dd2-dd1;}
else{yy=yy2-yy1-1;mm=11-(mm1-mm2);dd=30+dd2-dd1;}}
printf("\n%d yrs & %d months %d days old",yy,mm,dd);
printf("\n\ndo you want to repeat (y/n)? ");
getch(azim);
}
while(azim[0]!='n');
getch();
}
No comments:
Post a Comment
wait_i_will_reply_within_24_hours