Page 1 of 1

Quick Quiz #2 - Semicolons - Solutions

Posted: Sat Nov 29, 2014 11:06 am
by cfbsoftware
Please post your solutions and explanations to Quick Quiz #2 as a reply to this message.

Re: Quick Quiz #2 - Semicolons - Solutions

Posted: Sat Nov 29, 2014 11:38 am
by Robert
All - before it will compile to my satisfaction!
None - if you are not so picky.

Robert

Re: Quick Quiz #2 - Semicolons - Solutions

Posted: Sun Nov 30, 2014 11:44 am
by manumart1
How many semicolons need to be removed from the following code snippet before it will compile?
It does not say "can (optionally)", it says "need to".
My answer is: none of the semicolons need to be removed.

I know that the semicolon is a separator of statements, not a terminator, and that the empty statement was introduced in the language in order to admit a semicolon before "ELSE", "END", etc.
So, although I have not tested, I think that it would be even possible to write:

Code: Select all

IF j = 0 THEN;;;
;;ELSE;;
;END;;;
Regards,
Manuel

Re: Quick Quiz #2 - Semicolons - Solutions

Posted: Wed Dec 03, 2014 11:19 am
by Robert
I was gently criticising the question because what will compile is not the only merit criterion.

One might also want to give consideration to other factors, for example the Programming Conventions document that says
Semicolons are used to separate statements, not to terminate statements. This means that there should be no superfluous semicolons.
Robert