Array of structures

Array of structures

University

20 Qs

quiz-placeholder

Similar activities

JAVA - Arrays

JAVA - Arrays

University - Professional Development

15 Qs

PBO Inheritance Episode 2

PBO Inheritance Episode 2

University

18 Qs

Logika & Pemrograman (ID)

Logika & Pemrograman (ID)

10th Grade - Professional Development

20 Qs

PTS PROGDAS

PTS PROGDAS

1st Grade - University

20 Qs

4.6.4 Logic Gates

4.6.4 Logic Gates

10th Grade - Professional Development

15 Qs

Java Control and Loop -2

Java Control and Loop -2

University

20 Qs

Lenguaje de Definición de Datos

Lenguaje de Definición de Datos

University

18 Qs

Java Quiz 3

Java Quiz 3

University

15 Qs

Array of structures

Array of structures

Assessment

Quiz

Computers

University

Practice Problem

Medium

Created by

Karen Tan

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • 20 pts

Which of the following declares an array of structures of size 5, where each structure holds two integers (x and y)?

struct point arr[5];

struct point arr[] = {x: 1, y: 2};

struct point {int x; int y;} arr[5];

struct point arr = {1, 2};

2.

MULTIPLE CHOICE QUESTION

2 mins • 20 pts

What is the correct way to access the second element’s x field of an array of structures called points?

points.x[1];

points[0].x;

points[1].x;

points.x[2];

3.

MULTIPLE CHOICE QUESTION

2 mins • 20 pts

Given a pointer p to an array of structures, which statement accesses the third element's y field?

(*p[2]).y;

p[2].y;

(*p).y[2];

p->y[2];

4.

MULTIPLE CHOICE QUESTION

2 mins • 20 pts

Which of the following code snippets correctly traverses an array of structures points of size 5 and prints all the x values?

for (int i = 0; i arr[0] = 10;

struct data {int arr[5];} *d; d.arr[0] = 10;

5.

MULTIPLE CHOICE QUESTION

2 mins • 20 pts

Given the following code: struct point { int x; int y; }; struct point points[3] = {{1,2}, {3,4}, {5,6}}; What is the correct way to access the y value of the second point using a pointer to the array?

points[1]->y;

points->y;

points[2].y;

points[1].y;

6.

MULTIPLE CHOICE QUESTION

2 mins • 20 pts

What is the correct way to define a structure named 'circle' that contains a float for the radius and a point structure for the center?

struct circle {struct point center; float radius;};

struct circle {float radius; struct point center;};

struct circle {float radius; int center[2];};

struct circle {int center[2]; float radius;};

7.

MULTIPLE CHOICE QUESTION

2 mins • 20 pts

Given an array of structures 'shapes' of size 4, how can you access the y value of the first shape?

shapes[0].y;

shapes[1].y;

shapes.y[0];

shapes[0]->y;

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?