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)&&!(N%100==0)){
		cout<<"Month 1:"<<endl;
		int x1=d+6;
		while(x1<=31){
			cout<<x1<<endl;
			x1=x1+7;
		}
		cout<<"Month 2:"<<endl;
		int x2=d+3;
		while(x2<=29){
			cout<<x2<<endl;
			x2=x2+7;
		}
		cout<<"Month 3:"<<endl;
		int x3=d+2;
		while(x3<=31){
			cout<<x3<<endl;
			x3=x3+7;
		}
		cout<<"Month 4:"<<endl;
		int x4=d+6;
		while(x4<=30){
			cout<<x4<<endl;
			x4=x4+7;
		}
		cout<<"Month 5:"<<endl;
		int x5=d+4;
		while(x5<=31){
			cout<<x5<<endl;
			x5=x5+7;
		}
		cout<<"Month 6:"<<endl;
		int x6=d+2;
		while(x6<=30){
			cout<<x6<<endl;
			x6=x6+7;
			}
			cout<<"Month 7:"<<endl;
		int x7=d+6;
		while(x7<=31){
			cout<<x7<<endl;
			x7=x7+7;
			}
			cout<<"Month 8:"<<endl;
		int x8=d+3;
		while(x8<=31){
			cout<<x8<<endl;
			x8=x8+7;
			}
			cout<<"Month 9:"<<endl;
		int x9=d;
		while(x9<=30){
			cout<<x9<<endl;
			x9=x9+7;
			}
			cout<<"Month 10:"<<endl;
		int x10=d+5;
		while(x<=31){
			cout<<x10<<endl;
			x10=x10+7;
			}
			cout<<"Month 11:"<<endl;
		int x11=d+2;
		while(x11<=30){
			cout<<x11<<endl;
			x11=x11+7;
			}
			cout<<"Month 12:"<<endl;
		int x12=d;
		while(x12<=31){
			cout<<x12<<endl;
			x12=x12+7;
			}
			}
	else if (!(N%4==0)){cout<<"Month 1:"<<endl;
		int x13=d+6;
		while(x13<=31){
			cout<<x13<<endl;
			x13=x13+7;
		}
		cout<<"Month 2:"<<endl;
		int x=d+3;
		while(x<=28){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 3:"<<endl;
		int x=d+3;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 4:"<<endl;
		int x=d+6;
		while(x<=30){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 5:"<<endl;
		int x=d+4;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 6:"<<endl;
		int x=d+2;
		while(x<=30){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 7:"<<endl;
		int x=d+6;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 8:"<<endl;
		int x=d+3;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 9:"<<endl;
		int x=d;
		while(x<=30){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 10:"<<endl;
		int x=d+5;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 11:"<<endl;
		int x=d+2;
		while(x<=30){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 12:"<<endl;
		int x=d;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
			}
			}
		else if ((N%4==0)&&(N%100==0)&&!(N%400==0)){cout<<"Month 1:"<<endl;
		int x=d+6;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 2:"<<endl;
		int x=d+3;
		while(x<=28){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 3:"<<endl;
		int x=d+3;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 4:"<<endl;
		int x=d+6;
		while(x<=30){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 5:"<<endl;
		int x=d+4;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 6:"<<endl;
		int x=d+2;
		while(x<=30){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 7:"<<endl;
		int x=d+6;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 8:"<<endl;
		int x=d+3;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 9:"<<endl;
		int x=d;
		while(x<=30){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 10:"<<endl;
		int x=d+5;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 11:"<<endl;
		int x=d+2;
		while(x<=30){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 12:"<<endl;
		int x=d;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
			}
			}
		else if ((N%4==0)&&(N%400==0));{cout<<"Month 1:"<<endl;
		int x=d+6;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 2:"<<endl;
		int x=d+3;
		while(x<=29){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 3:"<<endl;
		int x=d+2;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 4:"<<endl;
		int x=d+6;
		while(x<=30){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 5:"<<endl;
		int x=d+4;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
		}
		cout<<"Month 6:"<<endl;
		int x=d+2;
		while(x<=30){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 7:"<<endl;
		int x=d+6;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 8:"<<endl;
		int x=d+3;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 9:"<<endl;
		int x=d;
		while(x<=30){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 10:"<<endl;
		int x=d+5;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 11:"<<endl;
		int x=d+2;
		while(x<=30){
			cout<<x<<endl;
			x=x+7;
			}
			cout<<"Month 12:"<<endl;
		int x=d;
		while(x<=31){
			cout<<x<<endl;
			x=x+7;
			}
			}
			}

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