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
- C# application that will allow users to enter values store all the expenses on that month in an array clothes, food, cool drinks, water, meatarrow_forwardA single statement that declares a variable and specifies array values as its content is called an array Select one: a.literal b.constructor C.element d.indexarrow_forwardint x[] = new int[]{10,20,30};Arrays can also be created and initialize as in above statement. A. True B. Falsearrow_forward
- Programming: Multi-Array Assignment Instructions Overview Using a two-dimensional array, you will create the game battleship using a text file that contains the board. The user will enter coordinates to try and find ships and sink them. Instructions Imagine you are using a two-dimensional array as the basis for creating the game battleship. In the game of battleship, a `~' character entry in the array represents ocean (i.e., not a ship), a `#' character represents a place in the ocean where part of a ship is present, and a `H' character represents a place in the ocean where part of a ship is present and has been hit by a torpedo. Thus, a ship with all `H' characters means the ship has been sunk. Declare a two-dimensional array that is 25 x 25 that represents the entire ocean and an If statement that prints "HIT" if a torpedo hits a ship given the coordinates X and Y. Create a text file of 25 line. Each line has 25 characters. ~ represents water and # represents part of…arrow_forwardProgramming: Multi-Array Assignment Instructions Overview Using a two-dimensional array, you will create the game battleship using a text file that contains the board. The user will enter coordinates to try and find ships and sink them. Instructions Imagine you are using a two-dimensional array as the basis for creating the game battleship. In the game of battleship, a `~' character entry in the array represents ocean (i.e., not a ship), a `#' character represents a place in the ocean where part of a ship is present, and a `H' character represents a place in the ocean where part of a ship is present and has been hit by a torpedo. Thus, a ship with all `H' characters means the ship has been sunk. Declare a two-dimensional array that is 25 x 25 that represents the entire ocean and an If statement that prints "HIT" if a torpedo hits a ship given the coordinates X and Y. Create a text file of 25 line. Each line has 25 characters. ~ represents water and # represents part of…arrow_forwardLook at the following array definition. int numbers[5] = { 1, 2, 3 };A) What value is stored in numbers[2]?B) What value is stored in numbers[4]?arrow_forward
- char[ ] letters=new char[5];int x = 0;while(x < 10){ar[x]='a';x++;}arrow_forwardPseudocode for the student grade calculator program, please Create a program to enter grades and calculate averages and letter grades. Need a class which will contain: Student Name Student Id Student Grades (an array of 3 grades) A constructor that clears the student data (use -1 for unset grades) Get functions for items a, b, and c, average, and letter grade Set functions for items a, n, and c Note that the get and set functions for Student grades need an argument for the grade index. Need another class which will contain: An Array of Students (1 above) A count of number of students in use You need to create a menu interface that allows you to: Add new students Enter test grades Display all the students with their names, ids, test grades, average, and letter grade Exit the program Add comments and use proper indentation. Nice Features: I would like that system to accept a student with no grades, then later add one or more grades, and when all grades are entered, calculate the…arrow_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_forward
- An array definition reserves space for the array. true or falsearrow_forwardProgramming Language: C++ Create a structure Student and ask the user how many students. Create an array which will save the number of students in the input. Ask for the data of the first and last student and display them.arrow_forwardWhen 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
- 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