2 Replies - 457 Views - Last Post: 29 June 2012 - 03:39 PM Rate Topic: -----

#1 Donor3  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-June 12

n00b Algorithm Question.

Posted 29 June 2012 - 02:32 PM

Hey guys,

I'm just starting out with understanding algorithms, but I had a quick question I can't find a direct answer to.

Say you had something that looked like this:

input X

if (0 <= X and <50)
output "Message1"

else if (50 <= X and X <70)
output "Message2"

else if (70 <= X and X <85)
output "Message3"

else if (85 <= X and X <100)
output "Message4"

end if
output "FinalMessage"


Would you get a "FinalMessage" output regardless of what you input you used?
Or would you only get the "FinalMessage" output if of the branches wasn't executed?

Thanks for your help!

Is This A Good Question/Topic? 0
  • +

Replies To: n00b Algorithm Question.

#2 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 856
  • View blog
  • Posts: 2,246
  • Joined: 28-March 11

Re: n00b Algorithm Question.

Posted 29 June 2012 - 03:17 PM

If none of the if statements matched your input, you would bet FinalMessage AND if one of your if statements executed, you would also get FinalMessage. You will get FinalMessage no matter what.
Was This Post Helpful? 0
  • +
  • -

#3 Donor3  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-June 12

Re: n00b Algorithm Question.

Posted 29 June 2012 - 03:39 PM

Alright, that's kind of what I was leaning toward but I just wanted to be sure.
Thanks for your help!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1