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 year;
int jan_1;
cin >> year >> jan_1;
int start_sun = 8 - jan_1;
int i = start_sun;
int j = 0;
int h = 0;
int k = 0;
int l = 0;
int m = 0;
int p = 0;
int s = 0;
int g = 0;
int w = 0;
int y = 0;
int q = 0;
if( year % 4 != 0 || year != 400 ) {
cout << "Month 1: ";
for( int i = start_sun; i <= 31; i += 7 ) {
	cout << i << " ";
}
	cout <<endl;
	j = 7 - ( 31 - i );
cout << "Month 2: ";
for( int j = 7 - ( 31 - i ); j <= 28; i += 7 ) {
        cout << j << " ";
}
	cout <<endl;
	h = 7 - (28 - j);
cout << "Month 3: ";
for( int h = 7 - ( 28 - j ); h <= 31; h += 7 ) {
        cout << h << " ";
}
	cout <<endl;
cout << "Month 4: ";
for( int k = 7 - ( 31 - h ); k <= 30; k += 7 ) {
        cout << k << " ";
}
        cout <<endl;
cout << "Month 5: ";
for( int l = 7 - ( 30 - k ); l <= 31; l += 7 ) {
        cout << l << " ";
}
        cout <<endl;
cout << "Month 6: ";
for( int m = 7 - ( 31 - l ); m <= 30; m += 7 ) {
        cout << m << " ";
}
        cout <<endl;	
cout << "Month 7: ";
for( int p = 7 - ( 30 - m ); p <= 31; p += 7 ) {
        cout << p << " ";
}
       cout <<endl;
cout << "Month 8: ";
for( int q = 7 - ( 31 - p ); q <= 31; q += 7 ) {
        cout << q << " ";
}
       cout <<endl;
cout << "Month 9: ";
for( int s = 7 - ( 31 - q ); s <= 30; s += 7 ) {
        cout << s << " ";
}
       cout <<endl;       
cout << "Month 10: ";
for( int g = 7 - ( 30 - s ); g <= 31; g += 7 ) {
        cout << g << " ";
}
       cout <<endl;
cout << "Month 11: ";
for( int w = 7 - ( 31 - g ); w <= 30; w += 7 ) {
        cout << w << " ";
}
       cout <<endl;
cout << "Month 12: ";
for( int y = 7 - ( 30 - w ); y <= 31; y += 7 ) {
        cout << y << " ";
}
       cout <<endl;
       }       
if( year % 4 == 0 && year % 100 != 0 ) {
cout << "Month 1: ";
for( int i = start_sun; i <= 31; i += 7 ) {
        cout << i << " ";
}
        cout <<endl;
        j = 7 - ( 31 - i );
cout << "Month 2: ";
for( int j = 7 - ( 31 - i ); j <= 29; i += 7 ) {
        cout << j << " ";
}
        cout <<endl;
        h = 7 - (29 - j);
cout << "Month 3: ";
for( int h = 7 - ( 29 - j ); h <= 31; h += 7 ) {
        cout << h << " ";
}
        cout <<endl;
cout << "Month 4: ";
for( int k = 7 - ( 31 - h ); k <= 30; k += 7 ) {
        cout << k << " ";
}
        cout <<endl;
cout << "Month 5: ";
for( int l = 7 - ( 30 - k ); l <= 31; l += 7 ) {
        cout << l << " ";
}
        cout <<endl;
cout << "Month 6: ";
for( int m = 7 - ( 31 - l ); m <= 30; m += 7 ) {
        cout << m << " ";
}
        cout <<endl;
cout << "Month 7: ";
for( int p = 7 - ( 30 - m ); p <= 31; p += 7 ) {
        cout << p << " ";
}
       cout <<endl;
cout << "Month 8: ";
for( int q = 7 - ( 31 - p ); q <= 31; q += 7 ) {
        cout << q << " ";
}
       cout <<endl;
cout << "Month 9: ";
for( int s = 7 - ( 31 - q ); s <= 30; s += 7 ) {
        cout << s << " ";
}
       cout <<endl;
cout << "Month 10: ";
for( int g = 7 - ( 30 - s ); g <= 31; g += 7 ) {
        cout << g << " ";
}
       cout <<endl;
cout << "Month 11: ";
for( int w = 7 - ( 31 - g ); w <= 30; w += 7 ) {
        cout << w << " ";
}
       cout <<endl;
cout << "Month 12: ";
for( int y = 7 - ( 30 - w ); y <= 31; y += 7 ) {
        cout << y << " ";
}
       cout <<endl;
       }
}

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: C