RUPAK SEARCH ENGINE

Custom Search

Get roll, name and two subjects marks of n students in a structure and display it.

// Get roll, name and two subjects marks of n students in a structure and display it.
#include
#include
struct age
{
float y,m,d;
}dob,now,dif;
void main()
{
age cal(age birth, age now);
clrscr();
printf("Enter year,month and date of date of birth:");
scanf("%f",&dob.y);
scanf("%f",&dob.m);
scanf("%f",&dob.d);

printf("Enter year,month,and date of system date");
scanf("%f",&now.y);
scanf("%f",&now.m);
scanf("%f",&now.d);
dif=cal(dob,now);
printf("\nRequired Age:\n:%.0f:",dif.y);
printf(" year %.0f",dif.m);
printf(" month %.0f day",dif.d);
getch();
}
age cal(age x, age y)
{
float temp1,temp2;
temp1=(y.y*365+y.m*60+y.d)-(x.y*365+x.m*60+x.d);
temp2=temp1;
while (temp2>=30)
{ temp2-=30;};
dif.d=temp2;
temp2=temp1/30;
while(temp2>=12)
{temp2-=12;};
dif.m=temp2;
dif.y=temp1/360;
return (dif);
}

No comments:

Post a Comment