In this tutorial, we learn new program which is to **Convert Days Into Years, Weeks and Days.**

This is a very simple program to implement.

Technic to used to implement this

1. To calculate year in given days ( nodays )

As we know 1 year has 365 days so dividing total days by 365 gives the answers which are a total year present on given days.

=> nodays / 365

2. To calculate weeks in given days

For this, we find modules of given number and 365. Which gives a reminder. This reminder we divide by 7.

=> (nodays % 365) / 7

3. To calculate days remaining in given days

For this, we find modules of given number and 365. Which gives a reminder. reminder we again apply modules by 7.

=> (nodays % 365) %7

**Example:**

Let’s us take total days = 500

Calculate years, weeks and days in total days using above technical

**Years**

=> years = days ÷ 365

=> years = 1

**Weeks**

=> weeks = ( days % 365 ) / 7

=> weeks = 500 % 365 => 135 / 7 => 19

**Days**

=> days = ( days % 365 ) %7

=> days = 500 % 365 => 135 % 7 => 2

## C Program to Convert Days Into Years, Weeks and Days

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#include<stdio.h> void main() { int nodays,years, weeks,days; printf("Enter the total days\n"); scanf("%d",&nodays); years=nodays/365; weeks=(nodays%365)/7; days=(nodays%365)%7; printf("%d = %d years,%d weeks,%d days\n",nodays,years,weeks,days); } |

**Output:**

**Enter the total days**

**500**

**500 = 1 years,19 weeks,2 days**

**Explanation**:

Initialized

nodays-number of days for input from a user

years – to store a number of years which is obtained by dividing a number of days by 365.

weeks- to store the number of weeks

days- to store a number of days.

Remaining is self-explanatory.