Question
1. Given an integer array named numbers that contains 22 elements. Write both a regular for loop, as well as a range-based for loop where
1. Given an integer array named numbers that contains 22 elements. Write both a regular for loop, as well as a range-based for loop where both loops display each of the elements in the array.
2. Given two double arrays named valueArray1 and valueArray2 that each have 42 elements, write the C++ code that will copy all the values from valueArray2 to valueArray1.
3. Compose the code necessary to declare a string array named countries that can hold up to fifteen entries. Also compose the code to declare an integer array named populations that can also hold up to fifteen entries. These two arrays are intended to be used in parallel. Assume that a different part of the program this code is part of will load values into the parallel arrays you declared. Show the code you created to declare these arrays along with code that will display each of the countrys names and their corresponding population values.
4. Is there anything seriously wrong with the following code? If so, explain and provide a remedy.
int SIZE = 25;
double values[SIZE];
for (int i = 1; i < SIZE; i++)
{
values[i] = 0.0;
}
5. Compose a C++ function that accepts an array of integer values and the number of entries in the array as arguments and returns the total of the values in the array as a double data type variable.
Programming Exercise (50 points):
Create a C++ program that asks the user to enter up to a maximum of 30 numbers. Inform the user that entering a sentinel value of -999 will terminate the data entry phase of the program. The program will store the numbers in an array of doubles and then display the following information:
- The lowest number in the array. (The number with the smallest value.)
- The highest number in the array. (The number with the greatest value.)
- The count of the number of valid entries made by the user. (Do not count entering the sentinel value as a valid entry.)
- The total of the numbers in the array.
- The average value of the numbers in the array.
1. Given an integer array named numbers that contains 22 elements. Write both a regular for loop, as well as a range-based for loop where both loops display each of the elements in the array.
2. Given two double arrays named valueArray1 and valueArray2 that each have 42 elements, write the C++ code that will copy all the values from valueArray2 to valueArray1.
3. Compose the code necessary to declare a string array named countries that can hold up to fifteen entries. Also compose the code to declare an integer array named populations that can also hold up to fifteen entries. These two arrays are intended to be used in parallel. Assume that a different part of the program this code is part of will load values into the parallel arrays you declared. Show the code you created to declare these arrays along with code that will display each of the countrys names and their corresponding population values.
4. Is there anything seriously wrong with the following code? If so, explain and provide a remedy.
int SIZE = 25;
double values[SIZE];
for (int i = 1; i < SIZE; i++)
{
values[i] = 0.0;
}
5. Compose a C++ function that accepts an array of integer values and the number of entries in the array as arguments and returns the total of the values in the array as a double data type variable.
Programming Exercise (50 points):
Create a C++ program that asks the user to enter up to a maximum of 30 numbers. Inform the user that entering a sentinel value of -999 will terminate the data entry phase of the program. The program will store the numbers in an array of doubles and then display the following information:
- The lowest number in the array. (The number with the smallest value.)
- The highest number in the array. (The number with the greatest value.)
- The count of the number of valid entries made by the user. (Do not count entering the sentinel value as a valid entry.)
- The total of the numbers in the array.
- The average value of the numbers in the array.
1. Given an integer array named numbers that contains 22 elements. Write both a regular for loop, as well as a range-based for loop where both loops display each of the elements in the array.
2. Given two double arrays named valueArray1 and valueArray2 that each have 42 elements, write the C++ code that will copy all the values from valueArray2 to valueArray1.
3. Compose the code necessary to declare a string array named countries that can hold up to fifteen entries. Also compose the code to declare an integer array named populations that can also hold up to fifteen entries. These two arrays are intended to be used in parallel. Assume that a different part of the program this code is part of will load values into the parallel arrays you declared. Show the code you created to declare these arrays along with code that will display each of the countrys names and their corresponding population values.
4. Is there anything seriously wrong with the following code? If so, explain and provide a remedy.
int SIZE = 25;
double values[SIZE];
for (int i = 1; i < SIZE; i++)
{
values[i] = 0.0;
}
5. Compose a C++ function that accepts an array of integer values and the number of entries in the array as arguments and returns the total of the values in the array as a double data type variable.
Programming Exercise (50 points):
Create a C++ program that asks the user to enter up to a maximum of 30 numbers. Inform the user that entering a sentinel value of -999 will terminate the data entry phase of the program. The program will store the numbers in an array of doubles and then display the following information:
- The lowest number in the array. (The number with the smallest value.)
- The highest number in the array. (The number with the greatest value.)
- The count of the number of valid entries made by the user. (Do not count entering the sentinel value as a valid entry.)
- The total of the numbers in the array.
- The average value of the numbers in the array.
1. Given an integer array named numbers that contains 22 elements. Write both a regular for loop, as well as a range-based for loop where both loops display each of the elements in the array.
2. Given two double arrays named valueArray1 and valueArray2 that each have 42 elements, write the C++ code that will copy all the values from valueArray2 to valueArray1.
3. Compose the code necessary to declare a string array named countries that can hold up to fifteen entries. Also compose the code to declare an integer array named populations that can also hold up to fifteen entries. These two arrays are intended to be used in parallel. Assume that a different part of the program this code is part of will load values into the parallel arrays you declared. Show the code you created to declare these arrays along with code that will display each of the countrys names and their corresponding population values.
4. Is there anything seriously wrong with the following code? If so, explain and provide a remedy.
int SIZE = 25;
double values[SIZE];
for (int i = 1; i < SIZE; i++)
{
values[i] = 0.0;
}
5. Compose a C++ function that accepts an array of integer values and the number of entries in the array as arguments and returns the total of the values in the array as a double data type variable.
Programming Exercise (50 points):
Create a C++ program that asks the user to enter up to a maximum of 30 numbers. Inform the user that entering a sentinel value of -999 will terminate the data entry phase of the program. The program will store the numbers in an array of doubles and then display the following information:
- The lowest number in the array. (The number with the smallest value.)
- The highest number in the array. (The number with the greatest value.)
- The count of the number of valid entries made by the user. (Do not count entering the sentinel value as a valid entry.)
- The total of the numbers in the array.
- The average value of the numbers in the array.
1. Given an integer array named numbers that contains 22 elements. Write both a regular for loop, as well as a range-based for loop where both loops display each of the elements in the array.
2. Given two double arrays named valueArray1 and valueArray2 that each have 42 elements, write the C++ code that will copy all the values from valueArray2 to valueArray1.
3. Compose the code necessary to declare a string array named countries that can hold up to fifteen entries. Also compose the code to declare an integer array named populations that can also hold up to fifteen entries. These two arrays are intended to be used in parallel. Assume that a different part of the program this code is part of will load values into the parallel arrays you declared. Show the code you created to declare these arrays along with code that will display each of the countrys names and their corresponding population values.
4. Is there anything seriously wrong with the following code? If so, explain and provide a remedy.
int SIZE = 25;
double values[SIZE];
for (int i = 1; i < SIZE; i++)
{
values[i] = 0.0;
}
5. Compose a C++ function that accepts an array of integer values and the number of entries in the array as arguments and returns the total of the values in the array as a double data type variable.
Programming Exercise (50 points):
Create a C++ program that asks the user to enter up to a maximum of 30 numbers. Inform the user that entering a sentinel value of -999 will terminate the data entry phase of the program. The program will store the numbers in an array of doubles and then display the following information:
- The lowest number in the array. (The number with the smallest value.)
- The highest number in the array. (The number with the greatest value.)
- The count of the number of valid entries made by the user. (Do not count entering the sentinel value as a valid entry.)
- The total of the numbers in the array.
- The average value of the numbers in the array.
Type or paste question here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started