Answer to Question #287328 in C++ for Abebe

Question #287328

Re write the following code fragment using one switch statement


if (ch = = ‘E’|| ch= = ‘e’)


cout<<" this is either the value of ‘E’ or ‘e’";


else if (ch = = ‘A’|| ch= = ‘a’)


cout<<" this is either the value of ‘A’ or ‘a’";


else if (ch = = ‘r’|| ch= = ‘i’)


cout<<" this is either the value of ‘i’ or ‘r’";


else


cout<<" Enter the correct choice";

1
Expert's answer
2022-01-13T09:39:29-0500
#include <iostream>
using namespace std;








int main() {
	char ch='e';
	switch(ch){
	case 'E':
	case 'e':
		cout<<" this is either the value of 'E' or 'e'";
		break;
	case 'A':
	case 'a':
		cout<<" this is either the value of 'A' or 'a'";
		break;
	case 'i':
	case 'r':
		cout<<" this is either the value of 'i' or 'r'";
		break;
	default:
		cout<<" Enter the correct choice";
		break;
	}
	


		


	cin>>ch;


	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