RE: If statements inside switch statements?

  • From: "Joseph Lee" <joseph.lee22590@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Mon, 26 Jul 2010 09:20:19 -0700

hi,
No, I don't think so. A switch statement is just a rewording of "if"
statements that looks a bit more like English. The problem with switch is
that you cannot test inclusive statements like:
if (something is less than this or greater than that)
{
// do something...
}
Whereas in switch statements, you need to provide case by case branches like
that from Tyler's code. (hopefully I might be wrong on that...).
If you want to test user responses after running the loop, you could try an
alternative, which is:
do\{
// your program code...
} while (response == "y");
This will ensure that the loop continues when the user answers "y" to our
prompt, otherwise (including "n") the computer will end the loop.
Hope this helps.
Cheers,
Joseph



-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jes
Sent: Monday, July 26, 2010 8:35 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: If statements inside switch statements?

Hi all,

Is it efficient on the computer's resources if I place an if statement
inside a switch statement?
The reason I ask is because for whatever reason, I can't get my else clause
to work. Switch, on the other hand, works just fine.
Jes

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.441 / Virus Database: 271.1.1/3027 - Release Date: 07/25/10
18:36:00

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: