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

Below I have shared the C++ program to convert given number of days into years, weeks and days.

 

For example if user has entered 365 days (not a leap year) then the output will be:

 

Years: 1
Weeks: 0
Days: 0

 

#include<iostream>

using namespace std;

int main()
{
	int y,d,w;

	cout<<"Enter No. of days:";
	cin>>d;
	
	y=d/365;
	d=d%365;
	w=d/7;
	d=d%7;

	cout<<"\nYears: "<<y<<"\nWeeks: "<<w<<"\nDays: "<<d;
	return 0;
}

 

If you have any problem regarding above years, weeks and days program then you can ask it by commenting below.

8 thoughts on “C++ Program to Convert Days Into Years, Weeks and Days”

    1. #include

      using namespace std;

      int main()
      {
      int y,d,m;

      cout<>d;

      y=d/365;
      d=d%365;
      m=d/30;
      d=d%30;

      cout<<"\nYears: "<<y<<"\nMonths: "<<m<<"\nDays: "<<d;
      return 0;
      }

Leave a Comment

Your email address will not be published. Required fields are marked *