Search Header Logo

Understanding 2D Arrays in C++

Authored by SITI (PMS)

Information Technology (IT)

University

Understanding 2D Arrays in C++
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct syntax to declare a 2D array in C++ with 3 rows and 4 columns of integer type?

`int arr[4][3];`

`int arr[3][4];`

`int arr(3)(4);`

`int arr{3}{4};`

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following correctly accesses the element in the second row and third column of a 2D array `arr`?

`arr[3][2]`

`arr[2][3]`

`arr[1][2]`

`arr[2][1]`

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the index of the first element in a 2D array in C++?

`[1][1]`

`[0][1]`

`[1][0]`

`[0][0]`

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a valid initialization of a 2D array in C++?

`int arr[2][3] = {1, 2, 3}, {4, 5, 6};`

`int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};`

`int arr[2][3] = [[1, 2, 3], [4, 5, 6]];`

`int arr[2][3] = {(1, 2, 3), (4, 5, 6)};`

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How many elements does a 2D array declared as `int arr[5][6]` contain in total?

11

25

30

36

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the value of `arr[1][2]` after the following initialization? ```cpp int arr[2][3] = {{10, 20, 30}, {40, 50, 60}}; ```

20

40

50

60

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following nested loop structures correctly iterates through all elements of a 2D array `arr[3][4]`?

`for(int i=0; i<4; i++) for(int j=0; j<3; j++)`

`for(int i=1; i<=3; i++) for(int j=1; j<=4; j++)`

`for(int i=0; i<3; i++) for(int j=0; j<4; j++)`

`for(int i=0; i<=3; i++) for(int j=0; j<=4; j++)`

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?