68 426
Assignments Done
98,6%
Successfully Done
In December 2018

Answer to Question #42930 in C++ for Amit malik

Question #42930
Write a programe that inputs an integer between 1 and 10 and use a switch statement to determine odd no. And the no. Which are a multiple of 4, otherwise the switch statement should inform the user that the entered no. Is neither even nor multiple of 4.
The programe should be repeated until the user enters -1, use a do while statement for repeat part
Expert's answer
#include<iostream>
using namespace std;
int main()
{
bool b = true;
int x;
do
{
cout << "Enter number from 1 to 10 (for EXIT type -1):";
cin >> x;
switch(x)
{
case -1:
b = false;
break;
case 1:
cout << "Neither even, nor multiple of 4\n";
cout << "\n";
break;

case 2:
cout << "Even, but not a multiple of 4\n";
cout << "\n";
break;

case 3:
cout << "Even, but not a multiple of 4\n";
cout << "\n";
break;

case 4:
cout << "Not even, but a multiple of 4\n";
cout << "\n";
break;

case 5:
cout << "Even, but not a multiple of 4\n";
cout << "\n";
break;

case 6:
cout << "Neither even, nor multiple of 4\n";
cout << "\n";
break;

case 7:
cout << "Even, but not a multiple of 4\n";
cout << "\n";
break;

case 8:
cout << "Not even, but a multiple of 4\n";
cout << "\n";
break;

case 9:
cout << "Neither even, nor multiple of 4\n";
cout << "\n";
break;

case 10:
cout << "Neither even, nor multiple of 4\n";
cout << "\n";
break;

default:
cout << "Please enter number from 1 to 10!\n";
cout << "\n";
break;

}
}while(b);
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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions