Write a C++ program which accepts total_days as integer and display total number of years, months and days in it.
Program Code:
Program Code:
#include<iostream>
using namespace std;
int main()
{
int total_days,year,month,days;
cout<<"Enter numbers of days : ";
cin>>total_days;
cout<<endl;
year = total_days / 365;
total_days = total_days % 365;
month = total_days / 30;
days = total_days % 30;
cout<<"Years : "<<year;
cout<,endl;
cout<<"Months : "<<month;
cout<<endl;
cout<<"Days : "<<days;
return 0;
}
The program code is tested on www.jdoodle.com
Output:
Enter numbers of days : 700
Years : 1
Months : 11
Days : 5
Thanks
Mukesh Rajput
Post A Comment:
0 comments: