Code:
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int MonthDays[13]= {0,31,28,31,30,31,30,31,31,30,31,30,31};
string MonthNames [13]={"Null","January","February","March","April","May","June","July","August","September","October","November","December"};
void printmonth( const int month, const int startday, const bool leapyear);
int main(void)
{
printmonth(1,0,false); //Print January, 1st on Sunday
printmonth(2,1,true); //Print February, 1st on Monday, Leap year
printmonth(3,2,false); //Print March, 1st on Tuesday
printmonth(4,3,false); //Print April, 1st on Wednesday
printmonth(5,5,false); //Print May, 1st on Friday
printmonth(6,6,false); //Print June, 1st on Saturday
printmonth(7,0,false); //Print July, 1st on Sunday
printmonth(8,1,false); //Print August, 1st on Monday
printmonth(9,2,false); //Print September, 1st on Tuesday
printmonth(10,3,false); //Print October, 1st on Wednesday
printmonth(11,4,false); //Print November, 1st on Thursday
printmonth(12,5,false); //Print December, 1st on Friday
system ("pause");
return 0;
}
void printmonth( const int month, const int startday, const bool leapyear)
{
int daysinmonth = MonthDays[month];
int daynumber=1;
int colCount=1;
cout << " " << MonthNames[month] << endl;
cout << endl;
cout <<" Sun"<<" "<<"Mon"<<" "<<"Tue"<<" "<<"Wed" <<" "<<"Thu"<<" "<<"Fri"<<" "<<"Sat"<<endl;
cout << endl;
while (daynumber <= daysinmonth)
{
colCount+1;
if (colCount == 8)
{
cout << endl;
colCount = 1;
}
cout << setw(4);
cout << daynumber;
colCount++;
daynumber++;
}
colCount = 1;
cout << endl << endl;
}
Alright there it is; functions merged and indented