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

#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;
}

Output

365 days (not a leap year) so the output will be:
 

Years: 1
Weeks: 0
Days: 0

Recent Posts

error: Alert: Content is protected!!