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 (Early Objects Version)
- Chapter # 8 (Arrays) Problem 1 1. Histogram Generate a text-based histogram for a sequence of grades to a class of students. The grades are l'A'- 'D', 'F'). Write a program that allows the user to enter grades of students in upper/lower case. As the grades are being entered, the program should count, using an array, the number of A's, the number of B's, the number of C's, the number of D's, and the number of F's. The program should be capable of handling an arbitrary number of student grades. However, the input should end when an invalid grade is encountered. To design your counters, use an array of size 5 where each array element is initialized to zero. Whenever an 'A" or 'a' is entered, increment array[0]. Whenever a 'B' or 'b' is entered, increment array[1], etc. up to array[4]. Output the histogram count and the bar- chart too as shown below. Sample input / output: Enter sequence of valid grade ['A'-'F'] ending with an invalid grade to stop: b BBc CA a a Ad DDda FFFBA A d e 7…arrow_forwardC++arrow_forwardQ3] (6 Marks) Suppose A is a one-dimension array with 12 elements is entered into list box. Write a program segment to find the location i such that A (i) contains the largest value in A. Also, find the smallest value with the location. Display the largest and smallest value and the location into textboxes, as shown in Figure 4. Form1 Array A 4 Largest value Location 5 -6 ? ? 21 3 Smallest value Location 1.5 31 15 -17 6. -13 Add Figure 4arrow_forward
- (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_forwardQ1) write a program to find the summation of 10 elemnets array. if the sum even, creas the array (set all element to zero) otherwise do nothing.arrow_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_forward
- Q1) Write a program to read the values of an array 4*9 , and then find the summation of the negative odd values that can be divided by 13.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_forwardM09.arrow_forward
- q2 ) In an array A[10], the last element is defined with index ________. a. Undefined b. 9 and 10 c. 10 d. 9arrow_forwardQ1 C) i) trace the output of the program ii) identify and EXPLAIN the algorithm used after the line statement //#####C in the program above.arrow_forwardQ1) List (with elaboration) all the components that a machine should contain in order to be classified as “Robot”?Q2) What is the purpose of NumPy in Python? Write a NumPy program to test if any of the elements of a given array are non-zero.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