Program to display a calendar

A program to display a calendar for any given year that the user puts in.
I need some help to arrange the days of the week in columns and put each of the days according to the days in the week. And also i need a line drawn after the letters of the days of the week.If anyone could,please guide me.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  
int main()
{
	int Y,n,W,C,y,i;
	cout << "Enter the year: ";
	cin >> Y,n;
	if (Y / 4 == 0)
	{
		if (Y / 100 != 0 || Y / 400 == 0) 
		{
			n = 364;
		}
	}
	else
		n = 365;
	C = (Y - 1) / 100;
	y = (Y - 1) % 100;
	W = ((29 - 2 * C + y + y / 4 + C / 4) % 7 + 7) % 7;
	cout <<  Y <<endl ;
	cout << "January\n";
	cout << "S M T W T F S";
	i = 1;
	while (i != 32)
	{
		cout << i;
		i++;
	}

Last edited on
:D

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
using namespace std;

int main()
{
	int Y,n,W,C,y;
	cout << "Enter the year: ";
	cin >> Y,n;
	if (Y / 4 == 0)
	{
		if (Y / 100 != 0 || Y / 400 == 0) 
		{
			n = 364;
		}
	}
	else
		n = 365;
	C = (Y - 1) / 100;
	y = (Y - 1) % 100;
	W = ((29 - 2 * C + y + y / 4 + C / 4) % 7 + 7) % 7;
	cout <<  Y <<endl ;
	cout << "January\n";
	cout << "S\tM\tT\tW\tT\tF\tS";
	
	for (int day=1;day!=32;day++){
		if (day==1) cout<<endl;
		cout<<day<<"\t";
		if (day==7||day==14||day==21||day==28) cout<<endl;
	}
}
Topic archived. No new replies allowed.