Search Header Logo

chapter 4- array

Authored by MAHANI BINTI ZAKARIA (POLIMAS)

Information Technology (IT)

University

Used 10+ times

chapter 4- array
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is an array in C++?

A single value that stores multiple variables

A data structure used to store multiple values of different types

A group of values stored in a single variable, all of the same type

A group of functions working together

Answer explanation

An array stores multiple values of the same data type (e.g. int, float, char) under one variable name. Each value is accessed by its index.

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following is the correct way to declare a one-dimensional array of 5 integers?

int number[5];

int number = [5];

array int[5];

int[5] number;

Answer explanation

The correct syntax to declare a one-dimensional array is:
data_type arrayName[size];
Here, int is the data type, number is the name, and [5] is the size.

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the index of the first element in an array in C++?

1

-1

0

10

Answer explanation

In C++, array indexing starts at 0. So, the first element is at index 0, second at index 1, and so on

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you access the third element in an array named marks?

marks(3);

marks[2];

marks[3];

marks{3};

Answer explanation

Array index starts from 0, so the third element is at index 2.
Syntax: arrayName[index]

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of this code?

int numbers[3] = {10, 20, 30};

cout << numbers[1];

10

20

30

Error

Answer explanation

In the array {10, 20, 30}, the index of 10 is 0, 20 is 1, and 30 is 2.
So, numbers[1] outputs 20.

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?