There is no "direct" solution: you can't have a "months" count without knowing the start date, including the year - as the length of February changes every four years.
But... if you want to accept inaccurate answers which assume a 30 day month as in your code, then it's easier than your think - sort of.
years = days / 365;
days = days % 365;
months = days / 30;
days = days % 30;
Since you are using integers throughout, the divide throws away any fractions, then the modulus throws away the bit you just calculated!
But do be aware: it produces rubbish results in the real world: such as 1 year, 12 months, 4 days if you enter 729!