Combining switch statements

How can i combine two different switch statements, as you can see these are two different statements and i want one "cout" statement for all three, is it possible?

case 1:
cout << "Showing the input:" << fixed << showpoint << setprecision(2) << number << endl;
break;
case 2:
case 3:
cout << "Showing the input:" << fixed << showpoint << setprecision(4) << number << endl;
break;
How do you want one cout statement for all three if case 1 is different from case 2 and 3?
That's the point, it is my homework question and i have no idea how is it possible. The exact words are : "I am expecting one “fall through” in the switch statement. The iomanip library holds setprecision and you will need to include it to get setprecision to work. You should have just one cout statement after the switch."
What you said doesnt mean you should combine them and only have one cout statement I think. What you did is correct, here is the fallthrough the problem asks for
1
2
3
4
case 2:
case 3:
cout << "Showing the input:" << fixed << showpoint << setprecision(4) << number << endl;
break;
. Now what it says is there should be one cout statement after the switch meaning there is a switch like this:

switch(something)
{
case 1:
bla bla
case 2:
bla bla

etc
}
Then here should be only one cout statement. Thats what I understood atleast. You should maybe post all the code to get a better understanding
Thank you very much, i did it by your example. Have a great day!!
No problem! Cheers!
Topic archived. No new replies allowed.