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;
	int Mon=1,Tue=2,Wed=3,Thurs=4,Fri=5,Sat=6,Sun=7,x;
	if(d==1){
		x=0;}
	else if(d==2){
		x=-1;}
	else if(d==3){
		x=-2;}
	else if(d==4){
		x=-3;}
	else if(d==5){
		x=-4;}
	else if(d==6){
		x=-5;}
	else{
		x=-6;}
	bool flag=true;
	if((n%4==0&&n%100!=0)||(n%4==0&&n%400==0){
			if(flag=true){
			cout<<"Month 1:"<<" ";
			while(x<=31){
			x=x+7;
			cout<<x<<" ";}
			cout<<endl;
			cout<<"Month 2:"<<" ";
			while(x<=60){
			x=x+7;
			cout<<x-31<<" ";}
			cout<<endl;
	        	cout<<"Month 3:"<<" ";
			while(x<=91){
			x=x+7;
			cout<<x-91<<" ";}
			cout<<endl;
			cout<<"Month 4:"<<" ";
			while(x<=121){
			x=x+7;
			cout<<x-121<<" ";}
			cout<<endl;
			cout<<"Month 5:"<<" ";
			while(x<=152){
			x=x+7;
			cout<<x-152<<" ";}
			cout<<endl;
			cout<<"Month 6:"<<" ";
			while(x<=182){
			x=x+7;
			cout<<x-182<<" ";}
			cout<<endl;
			cout<<"Month 7:"<<" ";
			while(x<=213){
			x=x+7;
			cout<<x-213<<" ";}
			cout<<endl;
			cout<<"Month 8:"<<" ";
			while(x<=244){
                        x=x+7;
                        cout<<x-244<<" ";}
                        cout<<endl;
                        cout<<"Month 9:"<<" ";
                        while(x<=274){
                        x=x+7;
                        cout<<x-274<<" ";}
                        cout<<endl;
                        cout<<"Month 8:"<<" ";
                        while(x<=305){
                        x=x+7;
                        cout<<x-305<<" ";}
                        cout<<endl;
                        cout<<"Month 9:"<<" ";
                        while(x<=335){
                        x=x+7;
                        cout<<x-335<<" ";}
                        cout<<endl;
			cout<<"Month 8:"<<" ";
                        while(x<=366){
                        x=x+7;
                        cout<<x-366<<" ";}
                        cout<<endl;
                               }}
                        else if(flag=true){
                        cout<<"Month 1:"<<" ";
                        while(x<=31){
                        x=x+7;
                        cout<<x<<" ";}
                        cout<<endl;
                        cout<<"Month 2:"<<" ";
                        while(x<=59){
                        x=x+7;
                        cout<<x-31<<" ";}
                        cout<<endl;                      
                        cout<<"Month 3:"<<" ";
                        while(x<=90){
                        x=x+7;
                        cout<<x-59<<" ";}
                        cout<<endl;
                        cout<<"Month 4:"<<" ";
                        while(x<=120){
                        x=x+7;
                        cout<<x-90<<" ";}
                        cout<<endl;
                        cout<<"Month 5:"<<" ";
                        while(x<=151){
                        x=x+7;
                        cout<<x-120<<" ";}
                        cout<<endl;
                        cout<<"Month 6:"<<" ";
                        while(x<=181){
                        x=x+7;
                        cout<<x-152<<" ";}
                        cout<<endl;
                        cout<<"Month 7:"<<" ";
                        while(x<=212){
                        x=x+7;
                        cout<<x-181<<" ";}
                        cout<<endl;
                        cout<<"Month 8:"<<" ";
                        while(x<=243){
                        x=x+7;
                        cout<<x-212<<" ";}
                        cout<<endl;
                        cout<<"Month 9:"<<" ";
                        while(x<=273){
                        x=x+7;
                        cout<<x-120<<" ";}
                        cout<<endl;
                        cout<<"Month 6:"<<" ";
                        while(x<=181){

Grading criterion: Leap Year Calculation
Rating A: All years correct (incl. Year % 400 = 0)
Rating B: Centuary Leap Year Correct (Year % 100 = 0 but Year % 400 != 0)
Rating C: Normal Leap Year correct (Year % 4 = 0 but Year % 100 != 0)
Rating D: Non-Leap Year also wrong (Year % 4 != 0)
Assigned grade: A