2 Dimensional Array

2 Dimensional Array

University

20 Qs

quiz-placeholder

Similar activities

Java - Revisão I

Java - Revisão I

University

20 Qs

C-Extended

C-Extended

University

16 Qs

C - Flow Control

C - Flow Control

University

20 Qs

Technical Assessment

Technical Assessment

University

20 Qs

DSA quiz

DSA quiz

University

20 Qs

C++ Quiz

C++ Quiz

University

20 Qs

C - Structures

C - Structures

University

20 Qs

Playing with C

Playing with C

University

20 Qs

2 Dimensional Array

2 Dimensional Array

Assessment

Quiz

Computers

University

Hard

Created by

Rommel Sario

Used 1+ times

FREE Resource

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

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?