# Write a Program in C++ & Python to convert a given number of days into years, weeks and days

Posted in Vinay Khatri
Last updated on June 8, 2022

Here in this program, we will discuss how to convert a given number of days into years. When a user will enter a number and our program will filter that number into years, weeks and days. For example, if the user enters 365 days the output should be 1 year 0 weeks 0 days Here we are not considering leap years.

### C++:

```#include<iostream.h>
#include<conio.h>
#include<math.h>

void main()
{
clrscr();
int ud,temp,w,d,y;
cout<<"Enter the days: ";
cin>>ud;
y= ud/365;
temp= ud%365;
w= temp/7;
d=temp%7;
cout<<"The number of years is: "<<y;
cout<<"\nThe number of weeks is: "<<w;
cout<<"\nThe number of days is: "<<d;
getch();
}```

Output:

```Enter the days: 253
The number of years is: 0
The number of weeks is: 36
The number of days is: 1```

### Python:

```ud = int(input("Enter the days: "))
y = ud//365
temp =ud%365
w= temp//7
d=temp%7
print("The number of years is:",y)
print("The number of weeks is:",w)
print("The number of days is:",d)```

Output:

```Enter the days: 253
The number of years is: 0
The number of weeks is: 36
The number of days is: 1```