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

Question 1 (1 point) Is the following code indented correctly? for (i=1; i< 10;

ID: 3902078 • Letter: Q

Question

Question 1 (1 point)

Is the following code indented correctly?

for (i=1; i< 10; i++)
{

cout << i << endl;
}

Question 1 options:

Save

Question 2 (1 point)

Is the following code indented correctly?

for (i=1; i< 10; i++) {
    cout << i << endl; }

Question 2 options:

Save

Question 3 (1 point)

Is the following code indented correctly?

for (i=1; i< 10; i++)
{

    cout << i << endl;
}

Question 3 options:

Save

Question 4 (1 point)

Is the following code indented correctly?

for (i=1; i< 10; i++) {
    cout << i << endl;
}

Question 4 options:

Save

Question 5 (1 point)

Is the following code indented correctly?

for (i=1; i< 10; i++)
{

    cout << i << endl;
}

Question 5 options:

Save

Question 6 (1 point)

Is the following code indented correctly?

for (i=1; i< 10; i++)
{  
cout << i << endl; }

Question 6 options:

Save

Question 7 (1 point)

Is the following code indented correctly?

for (i=1; i< 10; i++)
   {
cout << i << endl; }

Question 7 options:

Save

Question 8 (1 point)

Is the following code indented correctly?

for (i=1; i< 10; i++)  
    cout << i << endl;

Question 8 options:

Save

Question 9 (1 point)

Is the following code indented correctly?

for (i=1; i< 10; i++)
{
if (i % 2 == 0)
{
cout << i << endl;
}
}

Question 9 options:

Save

Question 10 (1 point)

for (i=1; i< 10; i++)
{
    if (i % 2 == 0)
    {
    cout << i << endl;
    }
}

Question 10 options:

Save

Question 11 (1 point)

for (i=1; i< 10; i++) {
    if (i % 2 == 0)
    {
        cout << i << endl;
    }
}

Question 11 options:

Save

Question 12 (1 point)

for (i=1; i< 10; i++)
if (i % 2 == 0)
cout << i << endl;

Question 12 options:

Save

Question 13 (1 point)

for (i=1; i< 10; i++)
    if (i % 2 == 0)
        cout << i << endl;

Question 13 options:

Save

Question 14 (1 point)

for (i=1; i< 10; i++) {
    if (i % 2 == 0) {
        cout << i << endl;
    }
}

Question 14 options:

Save

Question 15 (1 point)

Is the following indented correctly?

for (i=1; i< 10; i++)
{
if (i % 2 == 0)
{

cout << i << endl;
cout << i + 1 << endl;
}
}

Question 15 options:

Save

Question 16 (1 point)

Is the following indented correctly?

for (i=1; i< 10; i++)
{
    if (i % 2 == 0)
    {

        cout << i << endl;
      cout << i + 1 << endl;
    }
}

Question 16 options:

Save

Question 17 (1 point)

Is the following indented correctly?

for (i=1; i< 10; i++)
    if (i % 2 == 0)

        cout << i << endl;
        cout << i + 1 << endl;

Question 17 options:

Save

Question 18 (1 point)

Is the following indented correctly?

for (i=1; i< 10; i++)
    if (i % 2 == 0)

        cout << i << endl;
cout << i + 1 << endl;

Question 18 options:

True False

Explanation / Answer

K&R style of indentation is used in C++. For blocks inside a function in K&R style, the opening brace is at the same line as their respective control statements. The closing brace remains in its own line.

Question 1 False

Question 2 False

Question 3 False

Question 4 True

Question 5 False

Question 6 False

Question 7 False