Deck 7: Arrays
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/34
العب
ملء الشاشة (f)
Deck 7: Arrays
1
In the expression
cout << score[i] << endl;
i is called the
cout << score[i] << endl;
i is called the
index or subscript
2
The locations of the various indexed variables in an array can be spread out all over the memory.
False
3
Arrays can be passed to functions.
True
4
If you put a value in the square brackets of a one-dimension array parameter,this value is _________ by the compiler.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
5
A computer's memory consists of numbered locations called __________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
6
If a function is expecting a pass by reference parameter,you can pass an index variable from an array of the same base type to that function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
7
Write the declaration for a function named funct1 that expects an array of floats,the number of elements in the array and does not return any value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
8
If you use the const modifier in a function declaration,you do not include it in the function definition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
9
In the expression
double score[10];
double is called the ___________ of the array
double score[10];
double is called the ___________ of the array
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
10
The following array declaration is legal
double scores[]={0.1,0.2,0.3};
double scores[]={0.1,0.2,0.3};
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
11
If your index used to access the indexed variables of the array has the value of a non-existent index,this is called _________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
12
When you have a function that expects an array,it should also expect the size of the array or the number of indexed variables with valid data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
13
The following function will work with any size integer array.
void function1int array[],int numElements);
void function1int array[],int numElements);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
14
The modifier that guarantees that an array argument will not be changed is called ______.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
15
Arrays can be returned from a function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
16
The following function declaration guarantees the values in the array argument are not changed.
void function1int array[],int numElements);
void function1int array[],int numElements);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
17
Write the code to declare a two dimension array of integers with 10 rows and 20 columns.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
18
Write the code to declare an array of 10 doubles named list;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
19
The computer remembers the address of which indexed variables)in an array? ______
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
20
The indexed variables members)of an array must be integers.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
21
Given an array named scores with 25 elements,what is the correct way to access the 25th element?
A)scores+25
B)scores[24]
C)scores[25]
D)scores[last]
A)scores+25
B)scores[24]
C)scores[25]
D)scores[last]
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
22
What is wrong with the following code fragment?
Const int SIZE =5;
Float scores[SIZE];
Forint i=0; i<=SIZE;i++)
{
Cout << "Enter a score\n";
Cin >> scores[i];
}
A)Array indexes start at 1 not 0
B)Arrays must be integers
C)Array indexes must be less than the size of the array
D)Should be cin >> scores[0];
Const int SIZE =5;
Float scores[SIZE];
Forint i=0; i<=SIZE;i++)
{
Cout << "Enter a score\n";
Cin >> scores[i];
}
A)Array indexes start at 1 not 0
B)Arrays must be integers
C)Array indexes must be less than the size of the array
D)Should be cin >> scores[0];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
23
What are the valid indexes for the array shown below?
Int myArray[25];
A)0-25
B)0-24
C)1-25
D)1-24
Int myArray[25];
A)0-25
B)0-24
C)1-25
D)1-24
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
24
What is the output of the following code fragment?
Int array[4][4],index1,index2;
Forindex1=0;index1<4;index1++)
Forindex2=0;index2<4;index2++)
Array[index1][index2]=index1 + index2;
Forindex1=0;index1<4;index1++)
{
Forindex2=0;index2<4;index2++)
Cout << array[index1][index2] << " ";
Cout << endl;
}
A)0 1 2 3 1 2 3 4
2 3 4 5
3 4 5 6
B)0 1 2 3 0 1 2 3
0 1 2 3
0 1 2 3
C)0 0 0 0 1 1 1 1
2 2 2 2
3 3 3 3
D)0 0 0 0 0 1 2 3
0 2 4 6
0 3 6 9
Int array[4][4],index1,index2;
Forindex1=0;index1<4;index1++)
Forindex2=0;index2<4;index2++)
Array[index1][index2]=index1 + index2;
Forindex1=0;index1<4;index1++)
{
Forindex2=0;index2<4;index2++)
Cout << array[index1][index2] << " ";
Cout << endl;
}
A)0 1 2 3 1 2 3 4
2 3 4 5
3 4 5 6
B)0 1 2 3 0 1 2 3
0 1 2 3
0 1 2 3
C)0 0 0 0 1 1 1 1
2 2 2 2
3 3 3 3
D)0 0 0 0 0 1 2 3
0 2 4 6
0 3 6 9
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
25
Which of the following correctly declare an array that can hold up to 3 rows of 5 columns of doubles?
A)int array[3],[5];
B)int array[3][5];
C)float array[3][5];
D)float array[3,5];
A)int array[3],[5];
B)int array[3][5];
C)float array[3][5];
D)float array[3,5];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
26
An _______ is used to process a collection of data all of which is the same type
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
27
Why should you use a named constant for the size of an array?
A)Readability of code
B)Makes changes to the program easier
C)Helps reduce logic errors
D)All of the above
A)Readability of code
B)Makes changes to the program easier
C)Helps reduce logic errors
D)All of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
28
Given an array of integers of size 5,how does the computer know where the 3rd indexed variable is located?
A)It adds 3 to the base address of the array
B)It adds space for 3 integers to the base address of the array
C)It remembers where all the indexed variables of the array are located.
D)None of the above
A)It adds 3 to the base address of the array
B)It adds space for 3 integers to the base address of the array
C)It remembers where all the indexed variables of the array are located.
D)None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
29
What is wrong with the following code?
Float scores[10],total;
A)Cannot declare regular and array variables together.
B)Arrays must be integers
C)The 10 should be replaced with a variable name,whose value is input from the user
D)Nothing.
Float scores[10],total;
A)Cannot declare regular and array variables together.
B)Arrays must be integers
C)The 10 should be replaced with a variable name,whose value is input from the user
D)Nothing.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
30
Which of the following function declarations will accept the following two-dimension array?
Int pages[10][30];
A)void f1int pages[][],int size);
B)void f1int pages[][30],int size);
C)void f1int pages[10][],int size);
D)void f1int& pages,int size);
Int pages[10][30];
A)void f1int pages[][],int size);
B)void f1int pages[][30],int size);
C)void f1int pages[10][],int size);
D)void f1int& pages,int size);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
31
The individual variables that comprise an array are called __________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
32
If you need a function that will handle multi-dimensional arrays,you must specify the following sizes inside the square brackets.
A)All the sizes
B)All sizes except the last dimension
C)All sizes except the first dimension
D)None of the sizes
A)All the sizes
B)All sizes except the last dimension
C)All sizes except the first dimension
D)None of the sizes
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
33
Which of the following will read values from the keyboard into the array? Assume the size of the array is SIZE).
A)cin >> array;
B)cin >> array[];
C)cin >> array[SIZE];
D)fori=0;i> array[i];
A)cin >> array;
B)cin >> array[];
C)cin >> array[SIZE];
D)fori=0;i
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
34
Which of the following will correctly assign all the values in one array to the other array? Assume both arrays are of the same type and have SIZE elements)
A)array1=array2;
B)array1[]=array2;
C)fori=0;iD)fori=0;i
A)array1=array2;
B)array1[]=array2;
C)fori=0;i
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck