Computer Science Canada

I have a question...

Author:  lei4848 [ Mon Jun 19, 2006 9:53 pm ]
Post subject:  I have a question...

If an if statement containing many elsif parts and no else part

a) Only one of the conditions is allowed to be true; otherwise there is an error.
b) All the actions corresponding to true conditions are selected.
c) Only the first true condition (if any ) is selected.
d) At least one of the conditions is required to be true, otherwise there is a run-time error.
e) None of the above.

Author:  TheOneTrueGod [ Mon Jun 19, 2006 10:01 pm ]
Post subject: 

d)

Author:  Martin [ Mon Jun 19, 2006 10:17 pm ]
Post subject: 

No.

The answer is c). Try it out and see

code:

var x := 2
var y := 2
if x = 0 then
  put x
elsif x = 1 then
  put x
elsif x = 2 then
  put x
elsif y = 2
 puts "This isn't called!"
end if

Author:  Bored [ Tue Jun 20, 2006 7:57 am ]
Post subject: 

You shouldn't do peoples homework for them. This is obviously either a quiz question or homework question they don't know and are to lazy to check out.

Author:  TheOneTrueGod [ Tue Jun 20, 2006 8:01 am ]
Post subject: 

lol, I know, thats why I gave him the wrong answer... Have more faith in my Turing knowledge Confused

Author:  Bored [ Tue Jun 20, 2006 8:02 am ]
Post subject: 

I knew you did but it was Martin that was aimed at.

Author:  upthescale [ Tue Jun 20, 2006 2:39 pm ]
Post subject: 

Martin wrote:
No.

The answer is c). Try it out and see

code:

 puts "This isn't called!"


Seems liek Martin is familiar with Ruby...

Author:  aldreneo [ Wed Jun 21, 2006 12:42 pm ]
Post subject: 

Or perl...Or was that C

AHHH this is what happens when you lean 5 languages at once


: