# C programming question: what formula can i use to convert an input number of days into months and days?

for example, inputting 31 would output 1, 31 (jan 31)
32 --> outputs 2, 1 (feb 1)
60 --> outputs 3, 1 (march 1, assuming non-leap year)
how can i at least figure out which month would a given number of days correspond to?
it would be much simpler if each month only had 30 days; it would just be months =...
show more
for example, inputting 31 would output 1, 31 (jan 31)

32 --> outputs 2, 1 (feb 1)

60 --> outputs 3, 1 (march 1, assuming non-leap year)

how can i at least figure out which month would a given number of days correspond to?

it would be much simpler if each month only had 30 days; it would just be months = days/30. but, in this case, im taking into account that some months have 31 days, some 30, and then 28 for february (non-leap year). how can i achieve this?

32 --> outputs 2, 1 (feb 1)

60 --> outputs 3, 1 (march 1, assuming non-leap year)

how can i at least figure out which month would a given number of days correspond to?

it would be much simpler if each month only had 30 days; it would just be months = days/30. but, in this case, im taking into account that some months have 31 days, some 30, and then 28 for february (non-leap year). how can i achieve this?

Follow

3 answers
3

Are you sure you want to delete this answer?