Concept explainers
A)
Size declarator:
An array is a variable which stores multiple values of same types of data; the array values are stored in continuous memory locations.
Syntax of an array:
Datatype array-name [size-declarator];
Consider the following array definition:
//Declaration of array
int values[5];
In the above example, “int” represents the data type of an array. “values[]” is the array name and the number written inside the brackets is the size declaratory of the array.
- This size declarator must be an integer value which represents the number of elements that the array holds with it.
- In the above example code, it is clear that the array values can hold five elements with it.
B)
Size declarator:
An array is a variable which stores multiple values of same types of data; the array values are stored in continuous memory locations.
Syntax of an array:
Datatype array-name [size-declarator];
Consider the following array definition:
//Declaration of array
int values[5];
In the above example, “int” represents the data type of an array. “values[]” is the array name and the number written inside the brackets is the size declaratory of the array.
- This size declarator must be an integer value which represents the number of elements that the array holds with it.
- In the above example code, it is clear that the array values can hold five elements with it.
C)
Size declarator:
An array is a variable which stores multiple values of same types of data; the array values are stored in continuous memory locations.
Syntax of an array:
Datatype array-name [size-declarator];
Consider the following array definition:
//Declaration of array
int values[5];
In the above example, “int” represents the data type of an array. “values[]” is the array name and the number written inside the brackets is the size declaratory of the array.
- This size declarator must be an integer value which represents the number of elements that the array holds with it.
- In the above example code, it is clear that the array values can hold five elements with it.
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Starting Out with C++: Early Objects (9th Edition)
- int x[] = new int[]{10,20,30};Arrays can also be created and initialize as in above statement. A. True B. Falsearrow_forwardProject 5 - Magic Squares Objectives The objective of this project is to have students practice with two-dimensional arrays and loops. Specifications In this project, you will write code to determine if a two-dimensional array of ints is a Magic Square. For a two- dimensional array of ints to be a Magic Square all of the following must be true: 1. The array must be square - in other words, the lengths of all rows and all columns must be the same. 2. The array must contain all integers from 1 to n*n, where n is the length of the rows and columns. 3. The sum of the numbers in each diagonal, each row, and each column must be the same. You have been given two classes: • MagicSquareTest.java - Contains JUnit test cases for the MagicSquare class. Your code must pass all these tests. • MagicSquare.java - contains static methods to determine if a two-dimensional array of ints is a Magic Square: o isMagicSquare() - returns true if a two-dimensional array of ints meets all the criteria to be a…arrow_forwardAn array definition reserves space for the array. true or falsearrow_forward
- When traversing an array, which of the following statements does not need to keep track of the individual array subscripts: Do...Loop, For...Next, or For Each...Next?arrow_forward# Declare a named constant for array size here. MAX_AVERAGES = 8 # Declare array here. # Write a loop to get batting averages from user and assign to array. averageString = input("Enter a batting average: ") battingAverage = float(averageString) # Assign value to array. # Assign the first element in the array to be the minimum and the maximum. minAverage = averages[0] maxAverage = averages[0] # Start out your total with the value of the first element in the array. total = averages[0] # Write a loop here to access array values starting with averages[1] # Within the loop test for minimum and maximum batting averages. # Also accumulate a total of all batting averages. # Calculate the average of the 8 batting averages. # Print the batting averages stored in the averages array. # Print the maximum batting average, minimum batting average, and average batting average. This is on mindtap pyton what needs to be fixarrow_forwardTrue or False You can store a mixture of data types in an array.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_forward(Numerical) Write and test a function that returns the position of the largest and smallest values in an array of double-precision numbers.arrow_forwardGrade Book A teacher would like to assign a letter grade to a student, based on student's test score. Write a program to help this teacher managing her students' test score. Use the following grading scale to assign a letter grade to a student. Test Score Letter Grade 80 - 100 A 70 - 79 B 60 69 C 50 - 59 0- 49 F Your program must have an array of string objects to hold the student names and an array of int to hold the student scores. Let the teacher determines the number of students and ask the teacher to enter the information for each student. Your program should have the following programmer-defined functions: getInput () - to read the students name and scores from user getGrade () - to determine the letter grade corresponding to the score getReport () - to determine the maximum, minimum, average and standard deviation of the scores Display an error message if the teacher enter mark below 0 or above 100, and keep asking for a valid value. The program should also be capable of…arrow_forward
- An array can hold as much different data types as you want. True Falsearrow_forwardpython: numpy def purchases(transactions): """ QUESTION 7 - A high-end store is trying to evaluate the total amount that customer's spend per transaction. They want customers to spend anywhere between $130 and $150 on average. - You need to determine whether the average number spent on each transaction per month is above, between, or below the desired amount. - Transactions is a numpy array containing a date, total amount earned each month, and total number of transactions each month. - Above: month's average amount spent per transaction > 150 - Within Range: 150 >= month's average amount spent per transaction >= 130 - Below: month's average amount spent per transaction < 130 - Return a numpy array with "Above", "Within Range" and "Below" for the average amount spent per transaction per month - THIS MUST BE DONE IN ONE LINE HINT: use np.where() and convert the type of each column to float Args: transactions…arrow_forwardAn array is a single statement that declares a variable and provides array values as its content. Choose one: a.literal b.builder d.index C.elementarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning