Computer Science, asked by harshitwasd, 1 month ago

Write a program to enter number of days and print how may years, months, weeks and days will be formed. For eg; if the days entered is 1010 then the result should be : 2 years 9 months 1 week and 3 days. Assume that a year has 365 days and the month has 30 days

Answers

Answered by Nushrat109
2

Answer:

Plz mark me as Brainlist❤

Hope you understand☺

Explanation:

Given number of days, convert it in terms of Years, Week and Days.

Examples :

Input : 30

Output : years = 0

week = 4

days = 2

Input : 20

Output : years = 0

week = 2

days = 6

Approach :

Number of years will be the quotient when number of days will be divided by 365 i.e days / 365 = years.

Number of weeks will be the result of (Number_of_days % 365) / 7.

Number of days will be the result of (Number_of_days % 365) % 7.

Below is the program implementing above approach:

// C program to convert given

// number of days in terms of

// Years, Weeks and Days

#include <stdio.h>

#define DAYS_IN_WEEK 7

Output :

years = 0

weeks = 28

days = 4

Similar questions