A)
Explanation of Solution
Initialization of an array:
The C++ program allows the user to initialize the elements of an array while creating the array; the initialization list stores the value in an array in the specific order as they are initialized.
Example:
Consider the following snippet,
// Constant for the array size
const int num_of_days = 6;
// Initializing an array
int days[num_of_days] = {1, 2, 3, 4, 5, 6};
In the above example, the sequence of values are stored inside the braces and separated with commas is referred as initialization list.
Error in the given statement:
Consider the given statement,
// Initializing an array
int numbers[8] = {1,2, ,4, ,5};
In the above code, an error has been identified while initializing the values for the array “numbers”...
B)
Explanation of Solution
Implicit declaration of an array:
The C++ program allows the compiler to allocate a size for an array, which is not explicitly stated by the programmer.
Example:
Consider the following snippet,
// Initializing an array
int counter[] = {1, 2, 3, 4, 5, 6};
In the above example,the sequence of values are stored inside the braces and separated with commas. The compiler will automatically allocates an array of 6 integers...
C)
Explanation of Solution
Array elements:
The C++ program allows the user to initialize the elements of an array while creating the array; the array elements are of same data type and the type must be specified during the declaration.
Example:
Consider the following snippet,
// Initializing an array
int counter[] = {1, 2, 3, 4, 5, 6};
In the above example, the sequence of values are stored inside the braces and separated with commas. All elements in the array of int type.
Error in the given statement:
Consider the given statement,
// Initializing an array
values[3] = {6, 8...
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Starting Out With C++: Early Objects (10th Edition)
- Look at the following array definition. int numbers [] = {2, 4, 6, 8, 10};What will the following statement display?cout << *(numbers + 3) << end1;arrow_forwardWeather Statistics": Problem Statement: Write a program that uses a structure to store the following weather data for a particular month: Total Rainfall High Temperature Low Temperature Average Temperature The program should have an array of 12 structures to hold weather data for an entire year. When the program runs, it should ask the user to enter data for each month. (The average temperature should be calculated.) Once the data are entered for all the months, the program should calculate and display the average monthly rainfall, the total rainfall for the year, the highest and lowest temperatures for the year (and the months they occurred in), and the average of all the monthly average temperatures. Input Validation: Only accept temperatures within the range between -100 and +140 degrees Fahrenheit.arrow_forwardC programming language questionarrow_forward
- in c language typedef _people { int age; char name[ 32 ] ; } People_T ; People_T data [ 3 ]; Using string lib function, Assign 30 and Cathy to the first cell, Assign 40 and John to the second cell and Assign 50 and Tom to the third cellarrow_forwardC++ Programmingarrow_forwardC++ programming Chapter(s) Covered: Chapter 1-8 Concepts tested by the program: Working with one dimensional parallel arrays Use of functions Use of loops and conditional statements Project Description The Lo Shu Magic Square is a grid with 3 rows and 3 columnsshown below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 – 9 exactly. Each number 1 – 9must not be used more than once. So, if you were to add up thenumbers used, The sum of each row, each column and each diagonal all add upto the same number, Write a program that simulates a magic square using 3 onedimensional parallel arrays of integer type. Each one the arrays corresponds to a row of the magicsquare. The program asks the user to enter the values of the magicsquare row by row and informs the user if the grid is a magicsquare or not. See the sample outputs for more clarification. Project Specifications Input for this project: Values of the grid (row by row) Output for this…arrow_forward
- Grade 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(Data processing) A bank’s customer records are to be stored in a file and read into a set of arrays so that a customer’s record can be accessed randomly by account number. Create the file by entering five customer records, with each record consisting of an integer account number (starting with account number 1000), a first name (maximum of 10 characters), a last name (maximum of 15 characters), and a double-precision number for the account balance. After the file is created, write a C++ program that requests a user-input account number and displays the corresponding name and account balance from the file.arrow_forward(Statistics) Write a program that includes two functions named calcavg() and variance(). The calcavg() function should calculate and return the average of values stored in an array named testvals. The array should be declared in main() and include the values 89, 95, 72, 83, 99, 54, 86, 75, 92, 73, 79, 75, 82, and 73. The variance() function should calculate and return the variance of the data. The variance is obtained by subtracting the average from each value in testvals, squaring the values obtained, adding them, and dividing by the number of elements in testvals. The values returned from calcavg() and variance() should be displayed by using cout statements in main().arrow_forward
- Write a statement that declares a procedure-level one-dimensional array named intorders. The array should contain 15 elements.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(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
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr