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)
- 11.17 (Bucket Sort) Use Python. Show the whole code input and output when done. A bucket sort begins with a one-dimensional array of positive integers to be sorted and a two-dimensional array of integers with rows indexed from 0 to 9 and columns indexed from 0 to n – 1, where n is the number of values to be sorted. Each row of the two-dimensional array is referred to as a bucket. Write a class named BucketSort containing a function called sort that operates as follows: a) Place each value of the one-dimensional array into a row of the bucket array, based on the value’s “ones” (rightmost) digit. For example, 97 is placed in row 7, 3 is placed in row 3, and 100 is placed in row 0. This procedure is called a distribution pass. b) Loop through the bucket array row by row, and copy the values back to the original array. This procedure is called a gathering pass. The new order of the preceding values in the one-dimensional array is 100, 3 and 97. c) Repeat this process for each subsequent…arrow_forwardchar zetta[10] = {'B','A','D','G','U','Y','H','E',’L’,’P’}; Write a C programing code that will display the list of vowels and consonantsposition in the array, zetta.arrow_forward8.7 (Converting Strings to Integers for Calculations) Write a program that inputs six strings t hat represent integers, converts the strings to integers, and calculates the sum and average of the six values. Solve the problem step by step in c without using pointers And Make sure to provide the text based code tooarrow_forward
- 8.19 (Removing a Particular Word From a Given Line of Text) Write a program that inputs a line of text and a given word. The program should use string library functions strcmp and strcpy to remove all occurrences of the given word from the input line of text. The program should also count the number of words in the given line of text before and after removing the given word using the strtok function. Solve it Without using pointersarrow_forwardQ#03: Write C++ statements for the following: i. Create an array Matrix of type int of 25 elements.ii. Show the value of the 7th element of the array Matrix as its output.iii. In array Matrix, set the value of the 5h element to 35.iv. In array Matrix, set the value of the 9th element to the sum of the 6th and 13th elements of the array Matrix.v. In array Matrix, set the value of the 4th element of the array Matrix to three times the value of the 8th element minus 55.vi. Show the Output of array Matrix so that five elements per line are printed.arrow_forward6 43 2 Let A-7 3 4 6 5. 1. Using the column operator (;); create a column vector that contains all the columns of Aarrow_forward
- 2. Task 1: Using Single-Dimensional Array Write a C program that will accept 10 input values and will store the values in array. The program will also identify and print the minimum, maximum and average of input values. NOTE:Your source code must display any of the given sample output below.It means your source code should be flexible enough to meet any of the given sample output.Your source code output must be identical to any of the given sample output.It means you have to strictly follow what are the displayed text, labels, casing of characters in the sample output. OUTPUT 1: Input Value 1: 50 Input Value 2: 20 Input Value 3: 35 Input Value 4: 100 Input Value 5: 75 Input Value 6: 89 Input Value 7: 5 Input Value 8: 11 Input Value 9: 85 Input Value 10: 60 MIN Value: 5 MAX Value: 100 AVG Value: 53 OUTPUT 2: Input Value 1: 10 Input Value 2: 9 Input Value 3: 8 Input Value 4: 7 Input Value 5: 6 Input Value 6: 5 Input Value 7: 4 Input…arrow_forward// Program 4.7.1 #include <iostream>using namespace std;double getAverage(int *arr, int size); // function declaration:int main (){int balance[5] = {12, 34, 56, 78, 91}; // an int array with 5 elements.double avg;avg = getAverage( balance, 5 ) ; // pass pointer to the array as an argument.cout << "Average value is: " << avg << endl; // output the returned valuereturn 0;}double getAverage(int *ARRAY1, int size){int i, sum = 0;double avg;for (i = 0; i < size; ++i) { sum += ARRAY1[i]; }avg = double(sum) / size;return avg;} TASK 1. Explain in details what the program does? 2. What is the outputarrow_forwardDo question 11. Q11. Provide the output for the given C++ code about pointers. #include <iostream>using namespace std;int main(){char *ptr;char Str[] = "abcdefg";ptr = Str;ptr += 5;cout << ptr;return 0;} Q12. Provide the output for the given C++ code about arrays. #include <stdio.h>#include<iostream>using namespace std;int array1[] = {1200, 200, 2300, 1230, 1543};int array2[] = {12, 14, 16, 18, 20};int temp, result = 0;int main(){for (temp = 0; temp < 5; temp++){result += array1[temp];}for (temp = 0; temp < 4; temp++){result += array2[temp];}cout << result;return 0;} Q13. Provide the output for the given C++ code about arrays. #include <stdio.h>#include<iostream>using namespace std;int main (){int array[] = {0, 2, 4, 6, 7, 5, 3};int n, result = 0;for (n = 0; n < 8; n++){result += array[n];}cout << result;return 0;} Q14. Provide the output for the given C++ code about arrays. #include <stdio.h>#include <iostream>using…arrow_forward
- 8.20 (Counting the Number of Words in a String) Write a program that inputs several lines of t ext and uses strtok to count the total number of words. Assume that the words are separated by either spaces or newline characters Solve the problem in c without using pointersarrow_forward9.answwr the question jh. Using one line or two of Python code, declare a one-dimensional list called cityNames, and assign the values: Providence, Denver, Miami, Chicago, Seattle - Given the array you created above, what is the output of the line of Python below: - Given the array above, write a for statement (using Python syntax) that will output all of the entries in the array, one name at a time (one name per line)arrow_forwardAssume that an array of integers named a that contains exactly five elements has been declared and initialized. Write a single statement that assigns a new value to the first element of the array. This new value should be equal to twice the value stored in the last element of the array. Do not modify any values in the array other than the first element.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