• 0

Multiple case statements yield same result?


Question

case '5': case '6': case '7':
cout << " are you?" << endl;

This is a snippet of my code... what I'm trying to do is make something like "If the integer is equal to 5, 6, or 7, cout "are you?""

What's the proper way to do this?

I know I could do it all on separate lines, retyping the function, but I'd like to save some space.

EDIT: Nevermind. Problem fixed. I also fixed the code in the post just in case anyone else has a problem like this.

Edited by Ravager
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Also, you're not actually "saving" anything. When the code gets compiled, it makes absolutely no difference whether you put it all on one line, or stretched each item out to five; the compiled output is the same. So go for readability. :)

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.