Which of the following is a poor programming practice?

a) Nesting multiple repetition structures

b) Placing vertical spacing above and below control structures

c) Indenting the statements in the body of each control structure

d) Using float-point values for counters in counter-controlled repetition

1 Answer

  • D

    a)

    I assume they mean nesting loops with this. This is perfectly fine and probably the only acceptable way to program certain algorithms.

    b)

    I assume this means keeping an empty line above and below functions, methods and code. This is just programming style. If it improves the readability of the code, this is acceptable.

    c)

    This is a must to maintain good readability. Just take a look at code where there's no indention at all and code where there's indention where needed. The indented code is a lot easier to read. Fun fact: In the Python programming language, you must indent your code, otherwise it won't work as intended.

    d)

    If i read this correct, they mean counting with a floated point value in loops. I can't imagine any situation where you would want to do this. If you count something in a loop, always use integers.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts