# n00b Algorithm Question.

Page 1 of 1

## 2 Replies - 573 Views - Last Post: 29 June 2012 - 03:39 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=284325&amp;s=92aac5a8d500e519bd938f24cd5ad18e&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Donor3

Reputation: 0
• 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?

Is This A Good Question/Topic? 0

## Replies To: n00b Algorithm Question.

### #2 GunnerInc

• "Hurry up and wait"

Reputation: 900
• Posts: 2,346
• 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.

### #3 Donor3

Reputation: 0
• 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.