Program to convert given number of days into years, weeks and days
- Get number of days from user
- Divide number of days with 365 to get number of years
- For week take mod with 365 days and divide it with 7 you’ll get weeks
- And for days take mod with 365 and then take mode with 7 you’ll get days
C Code
#include <stdio.h>
#include<conio.h>
int main()
{
int y,w,d,a;
clrscr();
printf("Enter total number of days:");
scanf("%d",&d);
y=d/365;
a=d%365;
w=a/7;
d=a%7;
printf("\nYears: %d\nWeeks: %d\nDays: %d",y,w,d);
getch();
}
C++ Code
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int y,w,d,a;
cout << "Enter total number of days: ";
cin >> d;
y=d/365;
a=d%365;
w=a/7;
d=a%7;
cout << endl << "Years: "<< y
<< endl << "Weeks: " << w
<< endl << "Days: " << d;
return 0;
}
Output:
Other Related Search Terms
- C Program to convert given number of days into years, weeks and days
- C++ program to convert given number of days into years, weeks and days
- C and C++ program for check remaining years, weeks and days by giving number of days.

![[C/C++] Convert Given Number of Days into Years, Weeks and Days](https://fsconline.info/wp-content/uploads/2015/09/c-cpp-programming.jpg)

1 Comment
you forgot to mention leap year.