(Display the Sundays in a month) Write a program that prompts the user to enter the month and first day of the month, and displays all the Sundays in that month. For example, if the user entered the month 7 for July, and the first day 4 for Wednesday, your program should display the following output: The first day of this month is Wednesday! ... Next Sunday of this month is on 26

PHOTO EMBED

Mon Oct 26 2020 10:26:16 GMT+0000 (Coordinated Universal Time)

Saved by @mahmoud hussein #c++

#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;

int main()
{
	cout << "enter the month ";
	int month;
	cin >> month;
	cout << "Enter The First Day Of The Month ";
	int firstDay;
	cin >> firstDay;
	int nextSunday = 1;
	
		switch (firstDay)
		{
			
		case 1: nextSunday += 7;
			cout << "The first day of this month is sunday "<<endl;
			while (nextSunday < 30)
			{
					cout << "Next Sunday of this month is on " << nextSunday << endl;
									nextSunday += 7 ;
			}
			break;

		case 2: nextSunday += 6;
			cout << "The first day of this month is monday " << endl;
			while (nextSunday < 30)
			{
				cout << "Next Sunday of this month is on " << nextSunday << endl;
				nextSunday += 7;
			}
			break;
		case 3: nextSunday += 5;
			cout << "The first day of this month is tuesday " << endl;
			while (nextSunday < 30)
			{
				cout << "Next Sunday of this month is on " << nextSunday << endl;
				nextSunday += 7;
			}
			break;
		case 4: nextSunday += 4;
			cout << "The first day of this month is wednesday " << endl;
			while (nextSunday < 30)
			{
				cout << "Next Sunday of this month is on " << nextSunday << endl;
				nextSunday += 7;
			}
			break;
		case 5: nextSunday += 3;
			cout << "The first dayof this month is thursday " << endl;
			while (nextSunday < 30)
			{
				cout << "Next Sunday of this month is on " << nextSunday << endl;
				nextSunday += 7;
			}
			break;
		case 6: nextSunday += 2;
			cout << "The first day of this month is friday " << endl;
			while (nextSunday < 30)
			{
				cout << "Next Sunday of this month is on " << nextSunday << endl;
				nextSunday += 7;
			}
			break;
		case 7: nextSunday += 1;
			cout << "The first day of this month is saturday " << endl;
			while (nextSunday < 30)
			{
				cout << "Next Sunday of this month is on " << nextSunday << endl;
				nextSunday += 7;
			}
			break;

		}
		
}

	
	

content_copyCOPY

http://cpp.sh/