Search Header Logo

2 Dimensional Array

Authored by Rommel Sario

Computers

University

Used 1+ times

2 Dimensional Array
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

How do you declare a 2D array of integers with 3 rows and 4 columns in C?

int matrix(3,4);

int matrix[3][4];

int matrix{3,4};

int matrix(3)[4];

2.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

How can you access the element in the second row and third column of the matrix
int matriz[3][3];?

matriz[2][3]

matriz[1][2]

matriz[3][2]

matriz[2][1]

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What is the output of the following code?
int matrix[2][2] = { {1, 2}, {3, 4} };
printf("%d", matrix[1][0]);

1

2

3

4

4.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

How is a 2D array stored in memory?

Column-major order

Row-major order

Random memory allocation

Stored separately in different locations

5.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What will happen if you try to access matrix[3][2] in
int matrix[3][3];?

It will return garbage value

It will give a segmentation fault

It will return 0

It will run normally

6.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What is the correct way to iterate over a 3×3 matrix?

for(int i=0; i<3; i++)
for(int j=0; j<3; j++) printf("%d ", matrix[i][j]);

for(int i=0; i<3; j++) for(int j=0; i<3; i++) printf("%d ", matrix[i][j]);

for(int i=0; i<=3; i++) for(int j=0; j<=3; j++) printf("%d ", matrix[i][j]);

for(int i=1; i<=3; i++) for(int j=1; j<=3; j++) printf("%d ", matrix[i][j]);

7.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which of the following correctly initializes a 3×3 matrix with zero values?

int matrix[3][3] = {0};

int matrix[3][3] = {{0}};

int matrix[3][3] = { {0,0,0}, {0,0,0}, {0,0,0} };

All of the choices

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?

Discover more resources for Computers