Answer to Question #286281 in C++ for Eunice

Question #286281

1.      Analyze and debug the following program then display the output.

 

 

A.

#include <iostream>

using namespace std:

 

int main() {

 int i = 0;

 While (i < 5) {

   cout << i << "\n";

   i++;

 }

 return 0;

}

 

 

  B. 

#include <iostream>

using namespace std;

 

int main() {

            int day = 4;

          switch (Day) {

case1:

          cout << "Monday";

          break;

          case2:

          cout << "Tuesday";

          break:

            case3:

           cout << "Wednesday";

          break:

            case4:

           cout << "Thursday";

          break:

          case5:

          cout << "Friday";

           break:

          case6:

          cout << "Saturday";

           break:

          case7:

          cout << "Sunday";

            break:

 }

            return 0;

}

1
Expert's answer
2022-01-10T07:38:12-0500
#include <iostream>


using namespace std;
int main() {
	int i = 0;
	while (i < 5) {
		cout << i << "\n";
		i++;
	}
	cin>>i;
	return 0;
}




#include <iostream>
using namespace std;




int main() {


	int day = 4;


	switch (day) {
	case 1:


		cout << "Monday";


		break;


	case 2:


		cout << "Tuesday";


		break;


	case 3:


		cout << "Wednesday";


		break;


	case 4:


		cout << "Thursday";


		break;


	case 5:


		cout << "Friday";


		break;


	case 6:


		cout << "Saturday";


		break;


	case 7:


		cout << "Sunday";


		break;
	}
	cin>>day;
	return 0;
}





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment