Programming Concepts

Check your understanding - Pseudocode

What does the following pseudocode do?

If time <= 12 then
    greeting = 'Good morning'
Else If time <= 17 then
    greeting = 'Good afternoon'
Else
    greeting = 'Good evening'

Yes. Whether it is a good idea to anthropomorphise a program is another discussion!
No. The last 'Else' without a condition catches any instance when the previous two tests fail.
No. With selection, as soon as a test is satisfied, the following tests are skipped.
No. The initial test will catch the instance when the time is zero.
Well, Doctor, I think you will find that if we do time travel to a negative time, the greeting will be 'Good morning'. As a programmer it is for you to confirm the scope of the problem with the user.
← Previous 1 2 3 4 5 6 7 8 9 10 11 12 Next →