A)
Two-dimensional array:
A two dimensional array is also called as a multi-dimensional array; a multidimensional array is that all the identical arrays are put together into a single array.
- This is useful for storing same type of multiple sets of data in same place.
- The main advantage is that one-dimensional array can hold only one set of value whereas two-dimensional array can hold multiple sets of data in the form of rows and columns.
- The structure of a multi-dimensional array is look alike a table (that is combination of rows and columns); it contains same type of columns.
Given array declaration:
//Declaring multi-dimensional array
int temp[7][24];
The above statement creates a multidimensional array with “7” rows and “24” columns; the first square bracket is used to refer the number of rows and the second square bracket is used to refer the number of columns.
- Here row indicates day and column indicates a time such as 13 indicates 1 p.m, 12 indicates noon time and so on.
B)
Two-dimensional array:
A two dimensional array is also called as a multi-dimensional array; a multidimensional array is that all the identical arrays are put together into a single array.
- This is useful for storing same type of multiple sets of data in same place.
- The main advantage is that one-dimensional array can hold only one set of value whereas two-dimensional array can hold multiple sets of data in the form of rows and columns.
- The structure of a multi-dimensional array is look alike a table (that is combination of rows and columns); it contains same type of columns.
Given array declaration:
//Declaring multi-dimensional array
int temp[7][24];
The above statement creates a multidimensional array with “7” rows and “24” columns; the first square bracket is used to refer the number of rows and the second square bracket is used to refer the number of columns.
- Here row indicates day and column indicates a time such as 13 indicates 1 p.m, 12 indicates noon time and so on.
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Starting Out with C++: Early Objects (9th Edition)
- (Electrical eng.) Write a program that declares three one-dimensional arrays named volts, current, and resistance. Each array should be declared in main() and be capable of holding 10 double-precision numbers. The numbers to store in current are 10.62, 14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, and 3.98. The numbers to store in resistance are 4, 8.5, 6, 7.35, 9, 15.3, 3, 5.4, 2.9, and 4.8. Your program should pass these three arrays to a function named calc_volts(), which should calculate elements in the volts array as the product of the corresponding elements in the current and resistance arrays (for example ,volts[1]=current[1]resistance[1]). After calc_volts() has passed values to the volts array, the values in the array should be displayed from inside main().arrow_forward(Electrical eng.) Write a program that specifies three one-dimensional arrays named current, resistance, and volts. Each array should be capable of holding 10 elements. Using a for loop, input values for the current and resistance arrays. The entries in the volts array should be the product of the corresponding values in the current and resistance arrays (sovolts[i]=current[i]resistance[i]). After all the data has been entered, display the following output, with the appropriate value under each column heading: CurrentResistance Voltsarrow_forwardProblem2 Write a program that display the position of a given element in an array. You should print the index (i.e. the position) of the element. If the element appears more than one time than you should print all its positions. The size of the array should be entered by the user. If the element does not occur then you should display element not found. Sample1: Enter the size of the array: 5 Enter an array of size 5: 44 5 13 44 67 Enter the element to find: 44 44 is found at position 44 is found at position 44 occurs 2 time(s) Sample2: Enter the size of the array: 4 Enter an array of size 4: 12 150 17 20 Enter the element: 18 18 is not foundarrow_forward
- Programming language: Java Write a program do the following: 1- ask student to enter name 2- ask student to enter the number of school subjects 3- Declare an array the same size as the number of school subjects. 4- ask the students to enter the marks in the array. 5- display the student name and the marks.arrow_forwardThe task is to create a program that will randomly select four cards from a deck of 52 cards. All the cards can be represented using an array named deck, filled with initial values 0 to 51, as follows:Card numbers 0–12, 13–25, 26–38, and 39–51 represent 13 Spades, 13 Hearts, 13 Diamonds, and 13 Clubs, respectively, as shown in Figure 1. cardNumber / 13 determines the suit of the card, and cardNumber % 13 determines the rank of the card, as shown in Figure 2. After shuffling the array deck, pick the first four cards from deck. The program displays the cards from these four card numbers. Implement the following code in Eclipse, and ensure it runs without errors. Think about the following questions and write down your answers in a few sentences. 1) Describe how the above program shuffles the cards. 2) Describe how deck[i] / 13 and deck[i] % 13 work to display the suit and rank of cards.arrow_forwardYou can copy all elements of one array into one another with an assignment statement. True or Falsearrow_forward
- Monkey BusinessA local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 × 7 array, where each row represents a different monkey and each column represents a different day of the week. The monkeys are represented by integers 1, 2, and 3; the weekdays are "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". The program should first prompt the user to input the data for each monkey, starting with "Sunday" for monkey #1, then monkeys #2 and #3, followed by "Monday" for monkey #1, then monkeys #2 and #3 and so on, through "Saturday". The program then creates a report that includes the following information, each properly labeled (see below): Average amount of food eaten per day by the whole family of monkeys. The least amount of food eaten during the week by any one monkey. The greatest amount of food eaten during the week by any…arrow_forwardC++ program This assignment is about array operations. Create an array with 1000 items and fill it with random numbers from the range of -100, 100 (including -100 and 100). Then, your program asks user to enter a number. The program keeps running until user enters a out-of-range (-100,100) number. An example run is given below. Enter a number: -4Frequency of -4: 54Enter a number: 4Frequency of 4: 15Enter a number: 35Frequency of 35: 8Enter a number: 43Frequency of 43: 2Enter a number: 101Bye...arrow_forwardBelow is an application in which the number of days for each month in the year is stored in an array. (Forexample, January has 31 days, February has 28, and so on. Assume that the year is not a leap year.) Display 12sentences in the same format for each month; for example, the sentence displayed for January is Month 1 has 31days. Given the following pseudocode, fill in the missing lines of code (see bold portions):class MonthDaysmain() //Declarations num month num SIZE = 12 num DAYS finish declaring arraymonth = 0while month < SIZE output complete output statement month = ____________endwhilereturnendClassarrow_forward
- Question 1 Write a program that declares an array of 100 doubles. The program asks the user to enter a number N between 100, and then: initializes the first N elements of the array to random numbers between 1 and 100. calculates the average of these numbers and displays it. A final loop displays the elements of the array, each on a line, with an indication as to whether that number is lower or higher than the average. For example, if the numbers generated are 5, 28, 3, 8, 15, 7, 22, 6, 1, 4, then the program will print: Average = 9.9 5 28 3 8 15 7 22 6 1 4 11 11 11 -- 11 11 1- —— 11 lower than average higher than average lower than average lower than average higher than average lower than average higher than average lower than average lower than average lower than averagearrow_forwardAn array name, can begin with a number. Select one: True Falsearrow_forwardarrayarrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ 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
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,