Write a C++ program which accepts total_days as integer and display total number of years, months and days in it.

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


Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: