Concept explainers
Arrays
Write three statements to print the first three elements of array runTimes. Follow each statement with a newline. Ex: If runTime = {800, 775, 790, 805, 808}, print:
800
775
790
Note: These activities will test the code with different test values. This activity will perform two tests, both with a 5-element array (int runTimes[5]). See "How to Use zyBooks".
Also note: If the submitted code tries to access an invalid array element, such as runTime[9] for a 5-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message.
#include <iostream>
using namespace std;
int main() {
const int NUM_ELEMENTS = 5;
int runTimes[NUM_ELEMENTS];
int i;
for (i = 0; i < NUM_ELEMENTS; ++i) {
cin >> runTimes[i];
}
/* Your solution goes here */
return 0;
}
Please help me with this problem using c++.
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images
- 4. Array code Fill in the method below to have it create and fill in an array of 4 doubles. The first ele- ment should be set to the average of the first quarter of the array passed to data, the second element should be set to the average of the second quarter of the array, and so on. If input data is [1, 2, 3, 4, 5, 6, 7, 8] result should be [1.5, 3.5, 5.5, 7.5] public static double[] quartileAverages(int [] data) {arrow_forwardArrays Write three statements to print the first three elements of array runTimes. Follow each statement with a newline. Ex: If runTime = {800, 775, 790, 805, 808}, print:800 775 790 Note: These activities will test the code with different test values. This activity will perform two tests, both with a 5-element array (int runTimes[5]). See "How to Use zyBooks".Also note: If the submitted code tries to access an invalid array element, such as runTime[9] for a 5-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. #include <iostream>using namespace std; int main() {const int NUM_ELEMENTS = 5;int runTimes[NUM_ELEMENTS];int i; for (i = 0; i < NUM_ELEMENTS; ++i) {cin >> runTimes[i];} /* Your solution goes here */ return 0;} Please help me with this problem using c++.arrow_forward4. Fill in the table below to trace the values of the arrays in main at various points. int array1 = (10,20,30,40,50)}; int] array2 = (5,4,3,2,1}; intij array3 = new int[5]; Ilprint the array values at this point dolt(array1, array2); /print the array values at this point array2 = array1; Ilprint the values at this point array3 = dolt(array1,array2); Ilprint the array values at this point } llend of main public static int] dolt(int] arri, int] arr2){ int] arr3 = new int[5]; for (int i=0; icarr1.length;1++) arr3[1] = arr1[i]+arr2[arr2.length-1-i); return arr3; Values of the arrays below in main before first invocation of dolt array1 array2 array3 Values of the arrays below in main after first invocation of dolt array1 array2 array3 Values of the arrays below in main before second invocation of dolt array1 array2 Values of the arrays below in main after second invocation of dolt array1 array2 array3arrow_forward
- 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_forward(1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array of doubles. Output the array's numbers on one line, each number followed by one space. Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 142.0 Enter weight 4: 166.3 Enter weight 5: 93.0 You entered: 236.0 89.5 142.0 166.3 93.0 (2) Output the total weight, by summing the array's elements. (3) Output the average of the array's elements, with 2 decimal places. (4) Output the max array element. Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 142.0 Enter weight 4: 166.3 Enter weight 5: 93.0 You entered: 236.0 89.5 142.0 166.3 93.0 Total weight: 726.8 Average weight: 145.36 Max weight: 236 Code: import java.util.Scanner; public class PeopleWeights { public static void main(String[] args) { /* Type your code here. */ }}arrow_forward
- Bonus Question: For the same array as in the last question, explain what this statement does: x = &x[2]; Hint: draw a memory diagram to help yourself find the correct answer.arrow_forward3. Read in a series of integers and store the inputs in an array and then calls the RemoveEvens() function which takes three parameters: the array size and two integer arrays:arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education