0

write a programe to enter no. of days and conert it into months weeks and days

27th Sep 2016, 7:19 PM
Prakash Chandra Joshi
Prakash Chandra Joshi - avatar
3 Respostas
+ 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; }
27th Sep 2016, 8:17 PM
Zen
Zen - avatar
+ 1
Then provide info about how you want it.
27th Sep 2016, 8:55 PM
Zen
Zen - avatar
0
plz tell it in another method
27th Sep 2016, 8:52 PM
Prakash Chandra Joshi
Prakash Chandra Joshi - avatar