Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1 it is enough to follow best practices and coding conventions 80% of t

ID: 3876810 • Letter: Q

Question

Question 1

it is enough to follow best practices and coding conventions 80% of the time

options:

True
False


Question 2

indenting is cumulative, i.e. if we are inside of a double loop, we are indented once per loop

options:

True

False

Question 3

Which of the following is not a good programming practice?

options:

Commenting

Using short easy names for variables

Using descriptive names for variables

Following the guidelines of the group/team/industry


Question 4

The only single letter variable name should be the index of a for loop

options:

True
False


Question 5

indentation is a convention which depends on the company/team

options:

True

False


Question 6

A header should give the following information

options:

Name of the file

purpose

Author name i.e. a way to contact them

all of the above


Question 7

Best Programming Practices are important because

options:

We need to follow the guidelines of our company/team/industry

We maintain code and need it to be as clear as possible

We sometimes need to update our own code and it may have made sense a long time ago but we may not remember it

all of the above


Question 8

a variable names should be named using Hungarian notation, i.e. they should be of the form
typeFollowedByTheName is camelCasing

options:

True

False


Question 9

A function name is best defined as a verb

options:

True
False


Question 10

In the following loop
for (i = 0; i< 12; i++ ) {
    int months[] = {"jan", "feb", "mar", "apr", "jun", "jul", "aug", "sept", "oct", "nov", "dec"};
    ....
}

options:

the array gets created and destroyed for every iteration

The months are not going to change so the creation of the array month should move out of the loop.

both of the above

It is only a loop..


Question 11

The inside of any block is indented by one.

One = one tab or the equivalent of 4 spaces.

options:

True

False


Question 12

Cuddling an else means that the statement looks like this:
if (...) { // can be on the next line
} else {
}

options:

True

False


Question 13

A function can be of any length, including a couple of pages long

options:

True

False


Question 14

The arguments against cuddling an else are

options:

easy to move the code around

easy to comment the else code

both of the above

none of the above


Question 15

Indentation does not affect compilation

options:

True

False


ANSWER ALL PLEASE

Explanation / Answer

It is enough to follow best practices and coding conventions 80% of the time?

-- False
We need to follow best practices because the name says that they are the best.

Indenting is cumulative, i.e. if we are inside of a double loop, we are indented once per loop

-- True
Because if you have a for loop you will have one tab for the instructions in it. If you have one more inside then you will have 2 tabs for the instructions in it.

Which of the following is not a good programming practice?

-- Using short easy names for variables
Commenting, using descriptive names for variables and following the guidelines of the group/team/industry are considered to be good practices. Using short easy names doesn't make program self descriptive.

The only single letter variable name should be the index of a for loop

-- False
We can use any. Example: for(int index=0; ;)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote