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)
- Q3] (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_forwardChapter # 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_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_forward
- EXERCISE 27 Writing a function that calculates the occurrence of an integer A in an integer array T of size N. EXERCISE 28 Tis an array of N integers. N is defined as a constant equal to 10. Write a procedure proc1(int *T) that reads the N elements of the array by checking that the entered values are between 10 and 20. This procedure will display thereafter the N values of the array, the sum value, the maximum value and the minimum value of elements in this array.arrow_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
- C++ Visual 2019 1) Write a program that dynamically allocates an array large enough to hold a user-defined number of test scores. Once all the scores are entered, the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score. The program should display the sorted list of scores and averages with appropriate headings. Use pointer notation rather than array notation whenever possible. Input Validation: Do not accept negative numbers for test scores. 2) Modify your program so the lowest test score is dropped. This score should not be included in the calculation of the average.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_forwardQ1) 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_forward
- Array of Function Pointer Exercises 7.30 (Calculating Circle Circumference, Circle Area or Sphere Volume Using Function Pointers) Using the techniques you learned in Fig. 7.28, create a text-based, menu-driven program that allows the user to choose whether to calculate the circumference of a circle, the area of a circle or the vol- ume of a sphere. The program should then input a radius from the user, perform the appropriate calculation and display the result. Use an array of function pointers in which each pointer represents a function that returns void and receives a double parameter. The corresponding functions should cach display messages indicating which calculation was performed, the value of the radius and the result of the calculation.arrow_forwardQ1) Write a program to read the values of an array (7*3), and then find the product of even values that can be divided by 12.arrow_forwardq2 ) In an array A[10], the last element is defined with index ________. a. Undefined b. 9 and 10 c. 10 d. 9arrow_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