[CP 2] M2 - Arrays

studied byStudied by 0 people
0.0(0)
Get a hint
Hint

0

1 / 55

flashcard set

Earn XP

Description and Tags

56 Terms

1

0

If an array can store 100 values, what would be the first index?

New cards
2

1 5

What is the output of the following code?

\#include <iostream\>

using namespace std;

int main()

{

int a[] \= {1,2,3,4};

int b[] \= {5,6,7,8};

cout << a[0] << " " << b[0];

return 0;

}
New cards
3

int arr[3] = {1,2,3};

How do you initialize an array in C+?

New cards
4

double salary = balance[6];

Which of the following statements is correct?

New cards
5

1 3 5

What is the output of the program?

\#include <iostream\>

using namespace std;

int main()

{

int myArray[] \= {1,2,3,4,5};

for (int i \= 0; i<5; i++)

{

cout << myArray[i] << " ";

i++;

}

}
New cards
6

GRADE = A 65

What is the output of the following code?

\#include <iostream\>

using namespace std;

int main()

{

char grade[] \= {'A','B','C'};

int n \= grade[0];

cout << "GRADE \= " << grade[0] << " " << n ;

return 0;

}
New cards
7

49

What is the index number of the last element of an array with 50 elements?

New cards
8

linear array

A one dimensional array is also known as ___________________.

New cards
9

double price[5];

Which of the following correctly declares an array?

New cards
10

box[1];

Which of the following correctly gives the memory address of the first element in the array named box, an array with 100 elements?

box[one];

box[1];

box;

&box;

New cards
11

two dimensional array

It is an array that consists of more than one row and more than one column.

New cards
12

int a[6][2];

An array composed of 6 rows and 2 columns, what would be the array declaration?

New cards
13

0 0 1 2 2 4

\#include <iostream\>

using namespace std;

int main () {

int a[3][2] \= { {0,0}, {1,2}, {2,4} };

for ( int i \= 0; i < 3; i++ )

for ( int j \= 0; j < 2; j++ ) {

cout << a[i][j]<< " ";

}

return 0;

}
New cards
14

int x[50][2];

In order to have an array with 50 rows and 2 columns, the correct declaration should be:

New cards
15

99

What is the output of the given program?

\#include <iostream\>

using namespace std;

int main () {

int items[3][5] \= { {-1, 1, 3, 4, 45},

{4, 3, 99, 0, 7},

{3, 2, 66, 94,8}} ;

cout << items[1][2];

return 0;

}
New cards
16

3

In the array int x[3][4], how many rows were created?

New cards
17

6

In the array is int x[10][6], how many columns were created?

New cards
18

int my Array[20[20];

Which of the following is a two-dimensional array?

New cards
19

4

\#include <iostream\>

using namespace std;

int main () {

int a[5][2] \= { {0,0}, {1,2}, {2,4}, {3,6}, {4,8}};

int sum \= a[2][0]+a[1][1];

cout << sum << endl;

return 0;

}
New cards
20

int array[10];

Which of the following correctly declares an array?

New cards
21

3

In a given array int x[3][4] = {{0,1,2,3}, {4,5,6,7}, {8,9,10,11}}; how many rows are there?

New cards
22

x[0][3]

In a given array int x[3][4] = {{0,1,2,3}, {4,5,6,7}, {8,9,10,11}}; what is index contains 3?

New cards
23

Container of objects of similar types

Which of the following best describes an array?

New cards
24

An array is a series of elements of the same type in contiguous memory locations

What is the correct definition of an array?

New cards
25

box[6];

Which of the following correctly accesses the seventh element stored in an array named box with 100 elements?

New cards
26

27

What will be the output of the following C++ code?

\#include<iostream\>

using namespace std;

int main ()

{

int array[] \= {0, 2, 4, 6, 7, 5, 3};

int n, result \= 0;

for (n \= 0; n < 8; n++)

{

result +\= array[n];

}

cout << result;

return 0;

}
New cards
27

0

In a single dimension array, the starting index is always _____________.

New cards
28

myArray[3] = 3;

If an array myArray = {15, 45, 67, 34}, what statement should you choose to change the last value to 3?

New cards
29

array[9];

Which of the following accesses the tenth element stored in an array?

New cards
30

99

What is the index number of the last element of an array with 100 elements?

New cards
31

int arr2[15];

What is the correct array declaration?

New cards
32

all of the given

In C++, an Array is:

"an array contains more than one element a group of elements of the same type array elements are stored in memory in continuous or contiguous locations"

New cards
33

2 4 6 8

What is the output of the given program?

\#include <iostream\>

using namespace std;

int main()

{

int a[2][2] \= {{2,4},{6,8}};

int i, j;

for (i \= 0; i < 2; i++)

for (j \= 0; j < 2; j++)

cout << a[i][j] << " ";

return 0;

}
New cards
34

1

In an array, int a[3][2], what is the last index value of the column?

New cards
35

int a[3][5];

If you will be making a table of values, composed of 3 rows and 5 columns, what would be the array declaration?

New cards
36

columns

If the array has a syntax of data_type array_name[x][y]; What does y represent?

New cards
37

11

In the array is int arr[11][5], how many rows were created?

New cards
38

array

It refers to a table of rows and columns

New cards
39

int a[3][3];

If you will be making a table of values, composed of 3 rows and 3 columns, what would be the array declaration?

New cards
40

4

In the array is int x[3][4], how many columns were created?

New cards
41

19

What is the index number of the last element of an array with 20 elements?

New cards
42

float prices[3];

Which of the following correctly declares an array?

New cards
43

28

What is the index number of the last element of an array with 29 elements?

New cards
44

1 2 3 4 5 6

What is the output of the program?

\#include <iostream\>

using namespace std;

int main()

{

int myArray[] \= {1,2,3,4,5,6};

for (int i \= 0; i<6; i++)

{

cout << myArray[i] << " ";

}

}
New cards
45

90.5 92.5 96.5

What is the output of the following code?

\#include <iostream\>

using namespace std;

int main()

{

double marks[3] \= {90.5, 92.5, 96.5};

int a\=0;

while(a<3)

{

cout << marks[a] << " ";

a++;

}

return 0;

}
New cards
46

array

It is used to store multiple values in a single variable, instead of declaring separate variables for each value

New cards
47

Array

A series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier.

New cards
48

int x[5][10];

In order to have an array with 5 rows and 10 columns, the correct declaration should be:

New cards
49

14

What is the index number of the last element of an array with 15 elements?

New cards
50

array [2][1]

Check the array below:

int array[3][5]

{

{ 1, 2, 3, 4, 5 },

{ 6, 7, 8, 9, 10 },

{ 11, 12, 13, 14, 15 }

};

What's the index of the array where it contains the value 12?

New cards
51

100

In the array is int x[100][50], how many rows were created?

New cards
52

int a[6][4];

An array composed of 6 rows and 4 columns, what would be the array declaration?

New cards
53

int x[2][9];

In order to have an array with 2 rows and 9 columns, the correct declaration should be:

New cards
54

4

In a given array int x[3][4] = {{0,1,2,3}, {4,5,6,7}, {8,9,10,11}}; how many columns are there?

New cards
55

1234

What is the output of the program?

\#include <iostream\>

using namespace std;

int main()

{

int a[2][2] \= {{1,2},{3,4}};

int i, j;

for (i \= 0; i < 2; i++)

for (j \= 0; j < 2; j++)

cout << a[i][j];

return 0;

}
New cards
56

x[1][3]

In a given array int x[3][4] = {{0,1,2,3},

{4,5,6,7},

{8,9,10,11}};

What is index of 7?

New cards

Explore top notes

note Note
studied byStudied by 83 people
... ago
5.0(1)
note Note
studied byStudied by 16332 people
... ago
4.9(156)
note Note
studied byStudied by 131 people
... ago
5.0(1)
note Note
studied byStudied by 13 people
... ago
5.0(1)
note Note
studied byStudied by 208 people
... ago
5.0(1)
note Note
studied byStudied by 35 people
... ago
5.0(1)
note Note
studied byStudied by 81 people
... ago
5.0(1)
note Note
studied byStudied by 41100 people
... ago
4.9(218)

Explore top flashcards

flashcards Flashcard (85)
studied byStudied by 3 people
... ago
5.0(1)
flashcards Flashcard (21)
studied byStudied by 13 people
... ago
5.0(1)
flashcards Flashcard (98)
studied byStudied by 26 people
... ago
5.0(1)
flashcards Flashcard (100)
studied byStudied by 10 people
... ago
5.0(1)
flashcards Flashcard (61)
studied byStudied by 6 people
... ago
5.0(1)
flashcards Flashcard (63)
studied byStudied by 7 people
... ago
5.0(1)
flashcards Flashcard (67)
studied byStudied by 25 people
... ago
5.0(1)
flashcards Flashcard (31)
studied byStudied by 5 people
... ago
5.0(1)
robot