Exercises 7.6(Fill in the Blanks) Fill in the blanks in each of the following:
a) The names of the four elements of array p are ____, ____, ____ and ____.
b) Naming an array, stating its type and specifying the number of elements in the array is called ____ the array.
c) When accessing an array element, by convention, the first subscript in a two-dimensional array identifies an element's ____ and the second subscript identifies an element's ____.
d) An m-by-n array contains ____ rows, ____ columns and ____ elements.
e) The name of the element in row 3 and column 5 of array d is ____.
Fill in the blanks for the given statements related to arrays.
Explanation of Solution
- Given statement: The names of the four elements of array p are p[0], p [1], p[2] and p[3].
- Naming an array, stating its type and specifying the number of elements in the array is called declaring the array.
- When accessing an array element, by convention, the first subscript in a two-dimensional array identifies an element’s row number , and the second subscript identifies an elements’ column number.
- An m-by-n array contains m rows, n columns and m*n elements.
- The name of the element in row 3 and column 5 of array d is d[3][5].
To refer to any single element of the array are, you need to specify the name of the array and its position. Positions of elements of a n-size array are indexed from n = 0 till n − 1. So four elements of array p will be p[0], p[1], p[2], and p[3].
Declaration of array involved specifying the name of the array, along with its size and type. For example,
double p[10]; //declaration
This means an array of size 10, name p & type double has been declared.
An array comprises of rows & columns. The first subscript is row & second is column number. For example,
double p[9][10]- means element in the 9th row & 10th Column
The size of an array is given as the product of its row & columns. Example, for array a[10][2]- the total number of elements will be 10*2=20 and it will have 10 rows and 12 columns.
Name of element includes row & column number- with row number followed by column number.
Want to see more full solutions like this?
Chapter 7 Solutions
C++ How to Program (10th Edition)
- (Statistics) a. Write a C++ program that reads a list of double-precision grades from the keyboard into an array named grade. The grades are to be counted as they’re read, and entry is to be terminated when a negative value has been entered. After all grades have been input, your program should find and display the sum and average of the grades. The grades should then be listed with an asterisk (*) placed in front of each grade that’s below the average. b. Extend the program written for Exercise 1a to display each grade and its letter equivalent, using the following scale: Between90and100=AGreaterthanorequalto80andlessthan90=BGreaterthanorequalto70andlessthan80=CGreaterthanorequalto60andlessthan70=DLessthan60=Farrow_forwardQ.5) Part A Write a program in C++ language to print the number of elements that are divided by 5 without the remainder for one-dimensional array B on the screen, which has ten elements entering from the keyboard.arrow_forward3. a) java Declare an double array with 7 elements size and assign the values: 2, 4, 6, 8. b) Display the second and fourth element from an array.arrow_forward
- C++ Chapter 7 - 1D Array - The 3n + 1 problem, please give me a new solution, not the same solution in the questions bankarrow_forwardC++arrow_forwardDCS1101: Fundamental of Programming Tutorial 8 – Array 1. Define the following arrays: a) empNum, a 100 -element array of ints b) pay Rate, a 25-element array of doubles c) miles, a 14-element array of longs d) stateCapital, a 50-element array of string objects . e) lightYears, a 1,000-element array of doubles 2. Assume a program includes the following two statements. They both use square brackets, but they mean different things. int score[15] ; score[6] = 45 ; a) Which number is the size declarator ? b) Which number is a subscript? 3. What is the output of the following code? int values[5], count; for (count= 0; count< 5; count++) values[count ] =count+ 1; for (count= O; count< 5; count++) cout << values[count] << endl; 4. Complete the following program skeleton so it will have a 10-element array of int values called fish. When completed, the program should ask how many fish were caught by fishermen 1 through 10, and store this information in the array. Then it…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr