WorksheetsARRAY IN C++
Total questions: 15
Worksheet time: 8mins
How do you declare variables for 5 price of item?
float price1, price2, price3, price4, price5;
float price1to5;
float price(5);
float price[5];
■An array is a group of memory locations that have ______________________________.
the same name and different type
the same name
the same name and the same type.
the different name and type
Two types of Array are:
1 Dimensional Array and 2 Dimensional Array
2 Dimensional Array and 3 Dimensional Array
Linear Array and Dynamic Array
Sequence Array and Non-Sequence Array
Declaration statement for an array named arr with size 4 is
int arr[0];
int arr[5];
int arr(4);
int arr[4];
Declaration and initialize statement for an array named number with 1.1, 2.2 and 3.3 is written as
float number[2] = {1.1, 2.2, 3.3};
int number[3] = {1.1, 2.2, 3.3};
float number[3] = {1.1, 2.2, 3.3};
int a[5]={1,2,3,4,5};
The statement to display the third element of an array a is
cout<< a[2];
cout<< a[3];
Statement to display the fourth element of the array arr.
int arr[5]={12,23,31,42,51};
cout<< arr[4];
cout<< arr[3];
coding to display all character in the array for declaration mark:
char mark[5];
cout<<mark;
cout<<array mark;
cout<<array;
Unlike regular variables, __________ can hold multiple values.
constants
named constants
arrays
floats
Given the following declaration, where is the value 77 stored in the scores array?
int scores[] = {83, 62, 77, 97, 86}
scores[0]
scores[1]
scores[2]
scores[3]
What will the following code display?
int numbers[5] = {99, 87, 66, 55, 101};
for (int i = 1; i < 4; i++)
cout << numbers[i] << " ";
99 87 66 55 101
87 66 55 101
87 66 55
Nothing. This code has an error.
An array of string objects that will hold five names would be declared with which of the following statements?
string names[5];
string names(5);
string names 5;
String[5] = names;
Given the following declaration, where is the value 15 stored in the nums array?
int nums[] = {83, 15, 57, 87, 80}
nums[0]
nums[1]
nums[2]
nums[3]
What will the following code display?
int numbers[5] = { 66, 55, 101, 99, 87};
for (int i = 2; i < 5; i++)
cout << numbers[i] << " ";
87 101 99 87
101 99 87
66 101 87
Nothing. This code has an error.
