0
write a programe to enter no. of days and conert it into months weeks and days
3 Réponses
+ 4
Not accounting for leap years:
#include <iostream>
using namespace std;
int main() {
    unsigned int days, m, y;
    unsigned int daysInMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    cout << "Enter a number of days: ";
    cin >> days;
    cout << days << endl;
    m = 0;
    y = 0;
    while (days > daysInMonth[m]) {
        days -= daysInMonth[m];
        m++;
        if (m == 12) {
            m = 0;
            y++;
        }
    }
    cout << y*12+(m+1) << " months, " << days/7 << " weeks, and " << days%7 << " days" << endl;
    return 0;
}
+ 1
Then provide info about how you want it.
0
plz tell it in another method



