#include<stdio.h>//Its not showing the correct result//
int main()
{
int y,m,d;
scanf("%d",&d);
y=0;
m=0;
y=d/365;
d=d%365;
m=d/30;
d=d%30;
printf("%d ano(s)\n",&y);
printf("%d mes(es)\n",&m);
printf("%d dia(s)\n",&d);
return 0;
}
days to years,months,days conversion doesn't showing the correct result in c
95 Views Asked by Md Mehedi Hasan At
1
m=d/30;makes sense if all months had 30 days.They do not unless using another calendar like this.
Code needs to account for varying amount of days per month and leap years.
Save time. Enable all compiler warnings. Print the value, not the address.