C++ program that print out calendar using month and year as input. Fix out the error plx | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

C++ program that print out calendar using month and year as input. Fix out the error plx

#include<iostream #include<iomanip> #include<c.math> using namespace std; int GetDaysInMonth,Leaf Year,GetDayOfWeek bool IsLeafYear (const int year) { return ((year%400==0) || (year%4==0 && year%100!=0)); } int GetDaysInMonth (const int year, const int month) { switch (month) { case 2: return IsLeapYear(year) ? 29 : 28; case 4: case 6: case 9: case 11: return 30; default: return 31; } } int GetDayOfWeek(const int year, const int month) { /* 0 = Sunday */ const int d = 1; int y = year - (month < 3); static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; return (y + y/4 - y/100 + y/400 + t[month-1] + d) % 7; } void ShowCal(const int year, const int month) { string monthName[] = {"January","February","March","April","May","June","July", "August","September","October","November","December"}; int days = GetDaysInMonth(year, month); int dow = GetDayOfWeek(year, month); cout << monthName[month-1] << endl; cout << " Sun Mon

19th Oct 2021, 2:09 PM
Usman Bkolomi
Usman Bkolomi - avatar
0 Answers