URI Online Judge Solution | 1020 Age in Days

Solution:
Just think simple
if we take age input then if we want year then we have to divide the age with year,then if we want to find out the age in month as 1 year is 365 and 30 days of 12 months then we have to remainder and resultant value divided by 30 and at last for days of age we have to use remainder of 356 days and remainder of 30 respectively as 365 days for 1 year and 30 days for 1 months

#include<stdio.h>
int main()
{
    int a,year,month,days;
scanf("%d",&a);
year=a/365;
month=a%365/30;
days=a%365%30;
printf("%d ano(s)\n%d mes(es)\n%d dia(s)\n",year,month,days);
return 0;
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *