A)
Array:
An array is a data structure which stores multiple values of same types of data; the array values are stored in continuous memory locations.
- Size of an array has been declared inside a square bracket, which is named as size declarator.
- The size declarator must be declared as an integer with a value greater than “0” and the number inside the brackets represents the number of elements that the array can hold.
Syntax:
Syntax to declare an array,
data_type array_name[size_declarator];
Example:
Example to declare an array,
//Declaration of an array
int values[5];
In the above example, “int” represents the data type of the array, “values” is the array name and the number inside the bracket is the size declarator of the array.
- Here, the array “values” holds “5” values.
- The array index values starts from “0” and ends with “4” to hold five elements.
Given code:
/*array declaration of type double that can hold five values*/
double amount[5];
B)
Array:
An array is a data structure which stores multiple values of same types of data; the array values are stored in continuous memory locations.
- Size of an array has been declared inside a square bracket, which is named as size declarator.
- The size declarator must be declared as an integer with a value greater than “0” and the number inside the brackets represents the number of elements that the array can hold.
Syntax:
Syntax to declare an array,
data_type array_name[size_declarator];
Example:
Example to declare an array,
//Declaration of an array
int values[5];
In the above example, “int” represents the data type of the array, “values” is the array name and the number inside the bracket is the size declarator of the array.
- Here, the array “values” holds “5” values.
- The array index values starts from “0” and ends with “4” to hold five elements.
Given code:
/*array declaration of type double that can hold five values*/
double amount[5];
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Starting Out with C++: Early Objects (9th Edition)
- Programming language: Processing from Java Question attached as photo Topic: Use of Patial- Full Arraysarrow_forwardProblem Description - JAVA PROGRAMMING Use a Two-dimensional (3x3) array to solve the following problem: Write an application that inputs nine numbers, each of which is between 1 and 10, inclusive. Display the array after the user inputs each value. Rotate/flip the array by changing places. Make the rows columns and vice versa. You have to move the elements to their new locations. Remember to validate the input and display an error message if the user inputs invalid data. Documentation and the screenshot(s) of the results. Example: 1 2 3 4 5 6 7 8 9 the result will be : 1 4 7 2 5 8 3 6 9arrow_forwardLook at the following array definition.i nt values [1 OJ;A) How many elements does the array have?B) What is the subscript of the first element in the array?C) What is the subscript of the last element in the array?D) If an int uses four bytes of memory, how much memory does the array use?arrow_forward
- Problem2: 2D Arrays Define a 2D array using Java code that takes from a teacher the total number of rows and the total number of columns. Then let the teacher fill the array by students IDs and courses marks for each student. And print the following: 1- Print the array. 2- Print the marks that are less than 50 (mark < 50)arrow_forwardLook at the following array definition.int numberArray[9][11];Write a statement that assigns 145 to the first column of the first row of this array.Write a statement that assigns 18 to the last column of the last row of this array.arrow_forwardQuestion: How will you reference all elements in a one-dimensional array?arrow_forward
- Words: QUESTION 2 Write java program to create an array that read 5 double numbers. The program should display the array and the total number of all elements in the array.arrow_forwardJAVA PROGRAM: Monkey Business A 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 × 5 array, where each row represents a different monkey and each column represents a different day of the week. The program should first have the user input the data for each monkey, or use constant values rather than asking user for input. Then it should create a report that includes the following information: Display 3X5 array first. Average amount of food eaten per day by the whole family of The least amount of food eaten during the week by any one The greatest amount of food eaten during the week by any one Input Validation: Do not accept negative numbers for pounds of food eaten.arrow_forwardProblem Name: Two Sum Problem Description: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can assume that the input array is not sorted. Thanks.arrow_forward
- Question 16 Consider the following declaration: float decimal[50]; How many elements does the array have?arrow_forwardJAVA ARRAY MANIPULATION QUESTION: make a method called manipulator that takes a double array as parameter and modifies it. The method will modify the array then print the array. The method must modify the existing array, it CAN NOT create a different array as the solution. The manipulator method will be a void method. Remember: To get an average of 2 digits you add them together then divide by 2. Average of x and y = (x+y)/2 Modifications the method will do: For every 2 consecutive elements in the array, both the elements are replaced by their average. If the number of elements in an array is odd don't modify the last number of the array. Basically, you find the average of 2 consecutive elements then replace both of the elements with that value. Examples: Array = {2.0,3.0} will be changed to {2.5,2.5} when passed to the manipulator method Array = {2.0,3.0,45} will be changed to {2.5,2.5,45} when passed to the manipulator method Array = {2.0,3.0,45,55} will be changed to…arrow_forwardLook at the following array definition. double sales[8][10];A) How many rows does the array have?B) How many columns does the array have?C) How many elements does the array have?D) Write a statement that stores 3.52 in the last column of the last row in the array.arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT