Problem: Write a C++ program to take two inputs from the user, the year N, and d, the day of the week that January 1st falls on. Assume that the days are encoded as follows: (Mon: 1, Tues: 2, Wed: 3,   Sun: 7). Based on this, print all the dates on which Sunday falls on in that year.You must also take into account if the year is a leap year or not. The year is said to be a leap year if the year is divisible by four, except for end-of-century years where the year should be divisible by 400.

Example:Let s say you were interested in finding out all the dates when Sunday is going to be this year i.e. 2024, then the input to your code should be:2024 1Explanation for the above input: 2024 is the year and 1st Jan happened to be on Monday this year, hence was number-encoded as 1The output should list the dates of all Sundays in the year N, month-wise on a new line.

Constraints (Assume)1000 <= N (Year) <= 35001 <= d <= 12

Student submission:
#include<simplecpp>
main_program{
	int N,d;
cin>>N>>d;
  if(N%4!=0){
if(d=1){
	cout<<"month1: "<<"7 "<<"14 "<<"21 "<<"28"<<endl;
 cout<<"month2: "<<"4 "<<"11 "<<"18 "<<"25"<<endl;
 cout<<"month3: "<<"4 "<<"11 "<<"18 "<<"25 "<<endl;
 cout<<"month4: "<<"1 <<"8 "<<"15 "<<"22 "<<"29 "<<endl;
 cout<<"month5: "<<"6 "<<"13 "<<"20 "<<"27 "<<endl;
 cout<<"month6: "<<"3 "<<"10 "<<"17 "<<"24 "<<endl;
 cout<<"month7: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 "<<endl;
 cout<<"month8: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month9: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 "<<endl;
 cout<<"month10: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month11: "<<"4 "<<"11 "<<"18 "<<"25 "<<endl;
 cout<<"month12: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 "<<endl;
}
if(d=2){
        cout<<"month1: "<<"6 "<<"13 "<<"20 "<<"27"<<endl;
 cout<<"month2: "<<"3 "<<"10 "<<"17 "<<"24"<<endl;
 cout<<"month3: "<<"3 "<<"10 "<<"17 "<<"24 "<<"31 "<<endl;
 cout<<"month4: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month5: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month6: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 "<<endl;
 cout<<"month7: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month8: "<<"4 "<<"11 "<<"18 "<<"25 "<<endl;
 cout<<"month9: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 "<<endl;
 cout<<"month10: "<<"6 "<<"13 "<<"20 "<<"27 "<<endl;
 cout<<"month11: "<<"3 "<<"10 "<<"17 "<<"24 "<<endl;
 cout<<"month12: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 "<<endl;
if(d=3){
        cout<<"month1: "<<"5 "<<"12 "<<"19 "<<"26"<<endl;
 cout<<"month2: "<<"2 "<<"9 "<<"16 "<<"23"<<endl;
 cout<<"month3: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 " <<endl;
 cout<<"month4: "<<"6 "<<"13 "<<"20 "<<"27 "<<endl;
 cout<<"month5: "<<"4 "<<"11 "<<"18 "<<"25 "<<endl;
 cout<<"month6: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 "<<endl;
 cout<<"month7: "<<"6 "<<"13 "<<"26 "<<"27 "<<endl;
 cout<<"month8: "<<"3 "<<"10 "<<"17 "<<"24 "<<"31 "<<endl;
 cout<<"month9: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month10: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month11: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 "<<endl;
 cout<<"month12:<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
if(d=4){
        cout<<"month1: "<<"4 "<<"11 "<<"18 "<<"25"<<endl;
 cout<<"month2: "<<"1 "<<"8 "<<"15 "<<"22 "<<endl;
 cout<<"month3: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 " <<endl;
 cout<<"month4: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month5: "<<"3 "<<"10 "<<"17 "<<"24 "<<"31 "<<endl;
 cout<<"month6: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month7: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month8: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 "<<endl;
 cout<<"month9: "<<"6 "<<"13 "<<"20 "<<"27 "<<endl;
 cout<<"month10: "<<"4 "<<"11 "<<"18 "<<"25 "<<endl;
 cout<<"month11: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 "<<endl;
 cout<<"month12: "<<"6 "<<"13 "<<"20 "<<"27 "<<endl;
if(d=5){
        cout<<"month1: "<<"3 "<<"10 "<<"17 "<<"24 "<<"31 "<<endl;
 cout<<"month2: <<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month3: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month4: "<<"4 "<<"11 "<<"19 "<<"25 "<<endl;
 cout<<"month5: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 "<<endl;
 cout<<"month6: "<<"6 "<<"13 "<<"20 "<<"27 "<<endl;
 cout<<"month7: "<<"4 "<<"11 "<<"19 "<<"25 "<<endl;
 cout<<"month8: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 "<<endl;
 cout<<"month9: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month10: "<<"3 "<<"10 "<<"17 "<<"24 "<<"31 "<<endl;
 cout<<"month11: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month12: "<<"7 "<<"12 "<<"19 "<<"26 "<<endl;

if(d=6){
        cout<<"month1: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30  "<<endl;
 cout<<"month2: <<"6 "<<"13 "<<"20 "<<"27 "<<endl;
 cout<<"month3: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month4: "<<"3 "<<"10 "<<"18 "<<"24 "<<endl;
 cout<<"month5: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 "<<endl;
 cout<<"month6: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month7: "<<"3 "<<"10 "<<"18 "<<"24 "<<"31 "<<endl;
 cout<<"month8: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month9: "<<"4 "<<"11 "<<"18 "<<"25 "<<endl;
 cout<<"month10: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 "<<endl;
 cout<<"month11: "<<"6 "<<"13 "<<"20 "<<"27 "<<endl;
 cout<<"month12: "<<"6 "<<"11 "<<"18 "<<"25 "<<endl;

if(N%4==0){
	if(N%400!=0){if(d=1){
        cout<<"month1: "<<"7 "<<"14 "<<"21 "<<"28"<<endl;
 cout<<"month2: "<<"4 "<<"11 "<<"18 "<<"25"<<endl;
 cout<<"month3: "<<"4 "<<"11 "<<"18 "<<"25 "<<endl;
 cout<<"month4: "<<"1 <<"8 "<<"15 "<<"22 "<<"29 "<<endl;
 cout<<"month5: "<<"6 "<<"13 "<<"20 "<<"27 "<<endl;
 cout<<"month6: "<<"3 "<<"10 "<<"17 "<<"24 "<<endl;
 cout<<"month7: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 "<<endl;
 cout<<"month8: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month9: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 "<<endl;
 cout<<"month10: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month11: "<<"4 "<<"11 "<<"18 "<<"25 "<<endl;
 cout<<"month12: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 "<<endl;
}
}
if(d=2){
        cout<<"month1: "<<"6 "<<"13 "<<"20 "<<"27"<<endl;
 cout<<"month2: "<<"3 "<<"10 "<<"17 "<<"24"<<endl;
 cout<<"month3: "<<"3 "<<"10 "<<"17 "<<"24 "<<"31 "<<endl;
 cout<<"month4: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month5: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month6: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 "<<endl;
 cout<<"month7: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month8: "<<"4 "<<"11 "<<"18 "<<"25 "<<endl;
 cout<<"month9: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 "<<endl;
 cout<<"month10: "<<"6 "<<"13 "<<"20 "<<"27 "<<endl;
 cout<<"month11: "<<"3 "<<"10 "<<"17 "<<"24 "<<endif(d=3){
        cout<<"month1: "<<"5 "<<"12 "<<"19 "<<"26"<<endl;
 cout<<"month2: "<<"2 "<<"9 "<<"16 "<<"23"<<endl;
 cout<<"month3: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 " <<endl;
 cout<<"month4: "<<"6 "<<"13 "<<"20 "<<"27 "<<endl;
 cout<<"month5: "<<"4 "<<"11 "<<"18 "<<"25 "<<endl;
 cout<<"month6: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 "<<endl;
 cout<<"month7: "<<"6 "<<"13 "<<"26 "<<"27 "<<endl;
 cout<<"month8: "<<"3 "<<"10 "<<"17 "<<"24 "<<"31 "<<endl;
 cout<<"month9: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month10: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month11: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 "<<endl;
 cout<<"month12:<<"7 "<<"14 "<<"21 "<<"28 "<<endl;l;
 cout<<"month12: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 "<<endl;

}
if(d=3){
        cout<<"month1: "<<"5 "<<"12 "<<"19 "<<"26"<<endl;
 cout<<"month2: "<<"2 "<<"9 "<<"16 "<<"23"<<endl;
 cout<<"month3: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 " <<endl;
 cout<<"month4: "<<"6 "<<"13 "<<"20 "<<"27 "<<endl;
 cout<<"month5: "<<"4 "<<"11 "<<"18 "<<"25 "<<endl;
 cout<<"month6: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 "<<endl;
 cout<<"month7: "<<"6 "<<"13 "<<"26 "<<"27 "<<endl;
 cout<<"month8: "<<"3 "<<"10 "<<"17 "<<"24 "<<"31 "<<endl;
 cout<<"month9: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month10: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month11: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 "<<endl;
 cout<<"month12:<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
}
if(d=4){
        cout<<"month1: "<<"4 "<<"11 "<<"18 "<<"25"<<endl;
 cout<<"month2: "<<"1 "<<"8 "<<"15 "<<"22 "<<endl;
 cout<<"month3: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 " <<endl;
 cout<<"month4: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month5: "<<"3 "<<"10 "<<"17 "<<"24 "<<"31 "<<endl;
 cout<<"month6: "<<"7 "<<"14 "<<"21 "<<"28 "<<endl;
 cout<<"month7: "<<"5 "<<"12 "<<"19 "<<"26 "<<endl;
 cout<<"month8: "<<"2 "<<"9 "<<"16 "<<"23 "<<"30 "<<endl;
 cout<<"month9: "<<"6 "<<"13 "<<"20 "<<"27 "<<endl;
 cout<<"month10: "<<"4 "<<"11 "<<"18 "<<"25 "<<endl;
 cout<<"month11: "<<"1 "<<"8 "<<"15 "<<"22 "<<"29 "<<endl;
 cout<<"month12: "<<"6 "<<"13 "<<"20 "<<"27 "<<endl;
}

Grading criterion: Correct I/O incl. Format
Rating A: I/O Handled correctly
Rating B: Error in I/O
Rating C: 0
Rating D: 0
Assigned grade: B