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,lp,fsun,sund;
	cin>>N>>d;
	if (N%100==0){
		if(N%400==0){
			lp=1;
		}
		else{
			lp=0;}
	}
		
	else if (N%4==0){
		lp=1;}
       	else{
		lp=0;}
	
	fsun=8-d;
	sund=fsun;
	cout<<"Month 1: ";
	for(int i=sund; i<=31; i+=7){
		if(i>0){
			cout<<i<<" ";
			sund=i;}
		}
	sund-=31;

	cout<<endl<<"Month 2: ";
	if(lp==1){
		for(int flp=sund; flp<=29; flp+=7){
			if(flp>0){	
			cout<<flp<<" ";
			sund=flp;}}
		sund-=29;}
	else{
		for(int f=sund; f<=28; f+=7){
                	if(f>0){
				cout<<f<<" ";
                        	sund=f;}}
                sund-=28;}
	
	cout<<endl<<"Month 3: ";
	for(int mr=sund; mr<=31; mr+=7){
		if(mr>0){
        		cout<<mr<<" ";
        		sund=mr;}}
        sund-=31;
	
	
	cout<<endl<<"Month 4: ";
	for(int apr=sund; apr<=30; apr+=7){
		if(apr>0){
			
        		cout<<apr<<" ";
        		sund=apr;}}
        sund-=30;
	
	cout<<endl<<"Month 5: ";
	for(int may=sund; may<=31; may+=7){
		if(may>0){
                	cout<<may<<" ";
                	sund=may;}}
        sund-=31;

	cout<<endl<<"Month 6: ";
	for(int jun=sund; jun<=30; jun+=7){
                if(jun>0){
			cout<<jun<<" ";
               		sund=jun;}}
        sund-=30;


	cout<<endl<<"Month 7: ";
	for(int jul=sund; jul<=31; jul+=7){
		if(jul>0){
                	cout<<jul<<" ";
                	sund=jul;}}
        sund-=31;

	cout<<endl<<"Month 8: ";
	for(int aug=sund; aug<=31; aug+=7){
               	if(aug>0){
	       		cout<<aug<<" ";
                	sund=aug;}}
        sund-=31;

	cout<<endl<<"Month 9: ";
	for(int sep=sund; sep<=30; sep+=7){
                if(sep>0){
			cout<<sep<<" ";
                	sund=sep;}}
        sund-=30;
	
	cout<<endl<<"Month 10: ";
	for(int oct=sund; oct<=31; oct+=7){
                if(oct>0){
			cout<<oct<<" ";
                	sund=oct;}}
        sund-=31;

	cout<<endl<<"Month 11: ";
	for(int nov=sund; nov<=30; nov+=7){
                if(nov>0){
			cout<<nov<<" ";
                	sund=nov;}}
	sund-=30;


	cout<<endl<<"Month 12: ";
	for(int dec=sund; dec<=31; dec+=7){
                if(dec>0){
			cout<<dec<<" ";
                	sund=dec;}}
        sund-=31;
}

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