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 ;int d ;
	cin >> N >> d ;
	int k=0;
	if(d==1){
		k = d+6 ;}
	if(d==2){
		k=d+5;}
	if(d==3){
		k=d+4;}
	if(d==4){
		k=d+3;}
	if(d==5){
		k=d+2;}
	if(d==6){
		k=d+1;}
	if(d==7){
		k=d;}

	if( N%4==0 && N%400 != 0){
		cout << "Month 1: ";

		while(k<=31){
                       
                        cout << k<<" " ;
                        k = k+7 ;}
		cout << endl ;
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
		cout << "Month 2: ";
		cout << k-7 << " " ;
		while(k<=29){
                        
                        cout << k << " " ;
                        k = k+7 ;}
                k = 29 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
		cout<<endl;
		cout << "Month 3: ";
		cout << k-7 << " " ;

		while(k<=31){
                        
                        cout << k <<" ";
                        k = k+7 ;}
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
		cout<<endl;
                cout << "Month 4: ";
		cout << k-7 << " " ;

		while(k<=30){
                    
                        cout << k << " " ;
                        k = k+7 ;}
                k = 30 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
		cout<<endl;
                cout << "Month 5: ";
		cout << k-7 << " " ;

		while(k<=31){
         
                        cout << k<<" " ;
                        k = k+7 ;}
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
		cout<<endl;
                cout << "Month 6: ";
		cout << k-7 << " " ;

		while(k<=30){
                       
                        cout << k << " " ;
                        k = k+7 ;}
                k = 30 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
		cout<<endl;
                cout << "Month 7: ";
		cout << k-7 << " " ;

		while(k<=31){
               
                        cout << k << " " ;
                        k = k+7 ;}
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
		cout<<endl;
                cout << "Month 8: ";
		cout << k-7 << " " ;

		while(k<=31){
                       
                        cout << k << " " ;
                        k = k+7 ;}
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
		cout<<endl;
                cout << "Month 9: ";
		cout << k-7 << " " ;

		while(k<=30){
                     
                        cout << k << " " ;
                        k = k+7 ;}
                k = 30 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
		cout<<endl;
                cout << "Month 10: ";
		cout << k-7 << " " ;

		while(k<=31){
                       
                        cout << k << " " ;
                        k = k+7 ;}
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
		cout<<endl;
                cout << "Month 11: ";
		cout << k-7 << " " ;

		while(k<=30){
                      
                        cout << k << " " ;
                        k = k+7 ;}
                k = 30 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
		cout<<endl;
                cout << "Month 12: ";
		cout << k-7 << " " ;

		while(k<=31){
                    
                        cout << k << " " ;
                        k = k+7 ;}
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
	}

	else {
		cout << "Month 1: ";

                while(k<=31){

                        cout << k<<" " ;
                        k = k+7 ;}
                cout << endl ;
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
                cout << "Month 2: ";
		cout << k-7 << " " ;

                while(k<=28){

                        cout << k << " " ;
                        k = k+7 ;}
                k = 28 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
                cout<<endl;
                cout << "Month 3: ";
		cout << k-7 << " " ;

                while(k<=31){

                        cout << k <<" ";
                        k = k+7 ;}
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
                cout<<endl;
                cout << "Month 4: ";
		cout << k-7 << " " ;

                while(k<=30){

                        cout << k << " " ;
                        k = k+7 ;}
                k = 30 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
                cout<<endl;
                cout << "Month 5: ";
		cout << k-7 << " " ;
		 while(k<=31){

                        cout << k<<" " ;
                        k = k+7 ;}
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
                cout<<endl;
                cout << "Month 6: ";
		cout << k-7 << " " ;

                while(k<=30){

                        cout << k << " " ;
                        k = k+7 ;}
                k = 30 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
                cout<<endl;
                cout << "Month 7: ";
		cout << k-7 << " " ;

                while(k<=31){

                        cout << k << " " ;
                        k = k+7 ;}
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
                cout<<endl;
                cout << "Month 8: ";
		cout << k-7 << " " ;

                while(k<=31){

                        cout << k << " " ;
                        k = k+7 ;}
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
                cout<<endl;
                cout << "Month 9: ";
		cout << k-7 << " " ;
		while(k<=30){

                        cout << k << " " ;
                        k = k+7 ;}
                k = 30 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
                cout<<endl;
                cout << "Month 10: ";
		cout << k-7 << " " ;

                while(k<=31){

                        cout << k << " " ;
                        k = k+7 ;}
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
                cout<<endl;
                cout << "Month 11: ";
		cout << k-7 << " " ;

                while(k<=30){

                        cout << k << " " ;
                        k = k+7 ;}
                k = 30 - k  ;
                k = 7-k ;
                if(k==0){k=k+7;}
                cout<<endl;
                cout << "Month 12: ";
		cout << k-7 << " " ;

                while(k<=31){

                        cout << k << " " ;
                        k = k+7 ;}
                k = 31 - k  ;
                k = 7-k ;
                if(k==0){k=k+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