Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Arrays Intro

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.
Which declaration creates an array that holds 5 ints?
a)
int[5] hand = new int[5];
b)
int[5] hand = new int[];
c)
int[] hand = new int[5];
d)
int hand = new int[5];
2.
For the array:
double[] stats = new double[3];
What is the range of the index?
a)
0 to 3
b)
0 to 2
c)
1 to 3
d)
0 to 4
3.
//Which array will win?
string status = "Win";  
if(player[3] == 4)          
  status = "lose";
if(player[1] == 3)            
  status = "lose";
if(player[2] == 2)            
  status = "lose";
a)
{0,1,2,3}
b)
{1,3,2,4}
c)
{3,2,1,4}
d)
{3,2,4,5}
4.
//Which array will lose?
string status = "Win";
if(player[3] == 4)          
  status = "lose";
if(player[1] == 3)          
  status = "lose";
if(player[2] == 2)          
  status = "lose";
a)
{3,2,4,1}
b)
{1,2,3,4}
c)
{1,2,4,3}
d)
{3,4,1,2}
5.
for(int i=0; i<10; i++)
           numbers[i] = 2 * i + 1;
// Which index of the array holds the value of 5?
a)
1
b)
2
c)
3
d)
4
6.

for(int i=0;i<10;i++)

deck[2*i] = 5;

// Which statement will not print out 5?

a)

Console.WriteLine(deck[18]);

b)

Console.WriteLine(deck[0]);

c)

Console.WriteLine(deck[10]);

d)

Console.WriteLine(deck[20]);

7.

for(int i = 1; i<=100; i++)

numbers[i-1] = i/10;

//At what index will the first 2 occur?

a)

1

b)

2

c)

19

d)

20

8.

for(int i = 1; i<=100; i++)

numbers[i] = i%10;

//At what index will the first 5 occur?

a)

4

b)

5

c)

49

d)

50

9.

//cArray is filled with "c"s.

for(int i=1;i<100;i++)

if(i<11)

cArray[i] = "d";

//At what index will cArray

have its first "c"?

a)

0

b)

1

c)

11

d)

12

10.

Which is correct declaration of a 2D array with 5 rows and 2 columns?

a)

int [,] arrayTwoDee = new int [ 2 , 5 ];

b)

int [,] arrayTwoDee = new int [ 5 , 2 ];

c)

int [,] arrayTwoDee = new int [ 5 ; 2 ];

d)

int [,] arrayTwoDee = new int [ 2 . 5 ];

11.

Given this line: int[,] skateboards = { {80, 45}, {25, 10} }; What are the coordinates of 45?

a)

skateboards[1,1];

b)

skateboards[0,1];

c)

skateboards[0,0];

d)

skateboards[1,0];

e)

none of these

12.

Which array represents int[,] subject = new int[3, 2]; ?

a)

int[,] subject = { {20,18}, {13, 15}};

b)

int[,] subject = { {20,18,13} , {15, 17, 23}};

c)

int[,] subject = { {20,18}, {13, 15}, {17, 23} ;

d)

int[,] subject = { {20,18}, {13, 15}, {17, 23} };