C++ Program to Convert a Given Number of Days into Months and Days

In this program, the user is asked to enter the number of days, depending on it will display the months and days count.



Source Code
#include<iostream>
using namespace std;

int main()
{
    int days, months;
    cout<<"Enter days: ";
    cin>> days;
    months = days / 30;
    days = days % 30;
    cout<<"Months = " << months;
    cout<<"\nDays = " << days;
    return 0;
}
Output
Enter days: 265
Months = 8
Days = 25