Ravager Posted October 16, 2004 Share Posted October 16, 2004 (edited) 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 October 16, 2004 by Ravager Link to comment Share on other sites More sharing options...
0 Andareed Posted October 17, 2004 Share Posted October 17, 2004 Saving space is a bad reason for doing everything on one line. It is much clearer if you do one case statement per line. Link to comment Share on other sites More sharing options...
0 smurfiness Posted October 17, 2004 Share Posted October 17, 2004 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 More sharing options...
Question
Ravager
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 RavagerLink to comment
Share on other sites
2 answers to this question
Recommended Posts