C++ Program to Convert Days to Year, Month and Weeks

Write C++ Program to Convert Days to Year, Month and Weeks

// CPP Program to Convert Days to Year, Month and Weeks

#include <iostream>

using namespace std;

int main()
{
    int days, year, month, week, d;

    cout << "Enter Days :--> ";
    cin >> days;

    d = days;

    year = days / 365;
    days = days % 365;
    month = days / 30;
    days = days % 30;
    week = days / 7;
    days = days % 7;

    cout << d << " Days = " << year <<" Year, " << month << " Month, "
            << week << " Week and " << days << " days";
    return 0;
}

Output:

Enter Days :--> 438
438 Days = 1 Year, 2 Month, 1 Week and 6 days

≪ Previous | Next ≫