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<iostream>
using namespace std;
int main()
{
int N, d, n=1;
cin>>N>>d;

if (N%4==0 && N%100==0 && N%400!=0 && d==1)
{
cout<<"Month 1: 7 14 21 28"<<endl;
cout<<"Month 2: 4 11 18 25"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4==0 && N%100==0 && N%400!=0 && d==2)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4==0 && N%100==0 && N%400!=0 && d==3)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4==0 && N%100==0 && N%400!=0 && d==4)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4==0 && N%100==0 && N%400!=0 && d==5)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4==0 && N%100==0 && N%400!=0 && d==6)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}



else if (N%4==0 && N%100==0 && N%400!=0 && d==7)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}




else if (N%4==0 && N%100==0 && N%400!=0 && d==8)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}



else if (N%4==0 && N%100==0 && N%400!=0 && d==9)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}else if (N%4==0 && N%100==0 && N%400!=0 && d==10)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4==0 && N%100==0 && N%400!=0 && d==11)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4==0 && N%100==0 && N%400!=0 && d==12)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4!=0 && N%100==0 && N%400!=0 && d==1)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}


else if (N%4!=0 && N%100==0 && N%400!=0 && d==2)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}


else if (N%4!=0 && N%100==0 && N%400!=0 && d==3)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}


else if (N%4!=0 && N%100==0 && N%400!=0 && d==4)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4!=0 && N%100==0 && N%400!=0 && d==5)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4!=0 && N%100==0 && N%400!=0 && d==6)
{
cout<<"Month 1: 4 11 18 25"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%41!=0 && N%100==0 && N%400!=0 && d==7)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4!=0 && N%100==0 && N%400!=0 && d==8)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4!=0 && N%100==0 && N%400!=0 && d==9)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4!=0 && N%100==0 && N%400!=0 && d==10)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}


else if (N%4!=0 && N%100==0 && N%400!=0 && d==11)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}

else if (N%4!=0 && N%100==0 && N%400!=0 && d==12)
{
cout<<"Month 1: 1 8 15 22 29"<<endl;
cout<<"Month 2: 6 13 20 27"<<endl;
cout<<"Month 3: 3 10 17 24 31"<<endl;
cout<<"Month 4: 7 14 21 28"<<endl;
cout<<"Month 5: 5 12 19 26"<<endl;
cout<<"Month 6: 2 9 16 23 30"<<endl;
cout<<"Month 7: 7 14 21 28"<<endl;
cout<<"Month 8: 4 11 18 25"<<endl;
cout<<"Month 9: 1 8 15 22 29"<<endl;
cout<<"Month 10: 6 13 20 27"<<endl;
cout<<"Month 11: 3 10 17 24"<<endl;
cout<<"Month 12: 1 8 15 22 29"<<endl; 
}


}

Grading criterion: Quality and number of comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C