Just Started! Looking To Learn!

literally just signed up to this site and I am looking for/in need of some help! I have recently just started university and I have never coded c++ before in my life! Things are starting to get kind of tricky for me now! Any pointers to some books I could read that are helpful would be much appreciated!

ALSO!!

would any of you be able to help me off with this question I have for part of one of my assignments would be great!

Design and implement a program that outputs the calendar for the month in the following
format:
M T W Th F S Su
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

Arrange for your code to output seven lines for the calendar output even if some of those lines are empty. The data (input) for the program should consist of the number of days in the month and the day on which the month starts, such as 1 = Monday, 2 = Tuesday …

The input values of 30 and 7 would be required to get the output shown above.
Once you have a working programme, make a copy and adapt this so the program
continues until the user enters zero for the number of days in the month. You should also check for valid data (where possible) given the context of this program. Submit only the program that compiles and runs.

Call this program “Calendar.cpp”

also I cannot use anything like arrays or anything to that extent! it has to be out of for, while and do loops.

Thanks for any help on this would be appriciated! I am not asking for you to do my work! I just want some sort of guidance to the right way about doing it!
You would need to use mod, to show the 7 days in each week. As..

1
2
3
4
for(int day=1;day<31;day++)
cout << day << "  ";
if(day%7==0)
cout << endl;


This will print out the 30 days of the month.

Now, the rest is up to you.
you mean:

1
2
3
4
5
  for(int day=1;day<31;day++) {
	cout << day << "  ";
	if( day%7==0)
		cout << endl;
	}


Also, in the original post, the second line of output is obviously wrong as it contains 8 days.

You can try this resource:
http://www.programming4beginners.com/

@Kevin C

Yeah, I was doing the program quickly, and forgot the opening and closing brackets. Rookie mistake.. ;)

I did notice line 1 had 8 days, but all the rest have only 6. I figured when the OP creates the for loop, it should come out with the 7 days in each.

M     T     W     Th    F     S     Su
                                    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

Is actually what the output for 30 and 7 would be (being liberal with spacing).
1
2
3
4
5
6
7
8
for(int day=1;day<7;day++) 
	  cout << " " << "  ";
  for(int day=1;day<31;day++) 
      {
	  cout << day << "  ";
	  if( (day-1)%7==0)
		  cout << endl;
	  }
Last edited on
Topic archived. No new replies allowed.