# n00b Algorithm Question.

Page 1 of 1

## 2 Replies - 590 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=df7d178d7e82d89b0e6afecb49ffa2d6&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Donor3

• New D.I.C Head

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?

Thanks for your help!

Is This A Good Question/Topic? 0

## Replies To: n00b Algorithm Question.

### #2 GunnerInc

• "Hurry up and wait"

Reputation: 902
• Posts: 2,349
• 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

• New D.I.C Head

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.
Thanks for your help!
Was This Post Helpful? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }