HomeC++

How To Convert Days Into Years, Weeks and Days in C++ Program

How To Convert Days Into Years, Weeks and Days in C++ Program

We make Program in C++ to Convert Days Into Years, Weeks and Days.Now To Make it.
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++ Program to Convert Days Into Years, Weeks and Days

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int days,y,m,d;
cout<<"Enter no. of days : ";
cin>>days;
y=days/365;
days=days%365;
m=days/30;
d=days%30;
cout<<"Years : "<<y<<"\nMonths : "<<m<<"\nDays : "<<d;
return 0;
}

Output of ProgramC++ Program to Convert Days Into Years, Weeks and Days

Comments (0)

Leave a Reply