Single File Programming QuestionProblem statementRaj is working on a data analysis project and needs help creating a program that processes a 2D array. This program includes functions to calculate the average value of each row in a 2D array. The program should consist of several functions:calculateRowAverage(cols, row): Calculates the average of a single row in a 2D array.calculateAverages(rows, cols, arr, averages): Computes and stores the averages for each row in the 2D array.displayAverages(rows, averages): Displays the row number and its average value.Input format :The first line of input consists of two integers, rows and cols, representing the dimensions of the 2D array.The second line of input consists of the elements arr[i] of the 2D array, where each element is a double.Output format :The output displays the average value of each row as a double datatype value, rounded off two decimal points in the specified format:Average of each row:Row 1: [row1_avg]Row 2: [row2_avg]Row 3: [row3_avg]Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1 ≤ rows and cols ≤ 51.0 ≤ arr[i] ≤ 5.0Max_Rows and Cols = 100Sample test cases :Input 1 :3 31.7 2.9 3.54.2 5.7 6.87.2 8.1 9.6Output 1 :Average of each row:Row 1: 2.70Row 2: 5.57Row 3: 8.30Input 2 :2 26.8 1.25.6 8.9Output 2 :Average of each row:Row 1: 4.00Row 2: 7.25Input 3 :5 52.2 3.8 4.3 5.8 9.26.7 7.1 8.8 9.2 10.711.7 12.8 13.7 14.3 15.316.2 17.4 18.2 19.2 20.121.3 22.7 23.4 24.3 25.7Output 3 :Average of each row:Row 1: 5.06Row 2: 8.50Row 3: 13.56Row 4: 18.22Row 5: 23.48
Question
Single File Programming QuestionProblem statementRaj is working on a data analysis project and needs help creating a program that processes a 2D array. This program includes functions to calculate the average value of each row in a 2D array. The program should consist of several functions:calculateRowAverage(cols, row): Calculates the average of a single row in a 2D array.calculateAverages(rows, cols, arr, averages): Computes and stores the averages for each row in the 2D array.displayAverages(rows, averages): Displays the row number and its average value.Input format :The first line of input consists of two integers, rows and cols, representing the dimensions of the 2D array.The second line of input consists of the elements arr[i] of the 2D array, where each element is a double.Output format :The output displays the average value of each row as a double datatype value, rounded off two decimal points in the specified format:Average of each row:Row 1: [row1_avg]Row 2: [row2_avg]Row 3: [row3_avg]Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1 ≤ rows and cols ≤ 51.0 ≤ arr[i] ≤ 5.0Max_Rows and Cols = 100Sample test cases :Input 1 :3 31.7 2.9 3.54.2 5.7 6.87.2 8.1 9.6Output 1 :Average of each row:Row 1: 2.70Row 2: 5.57Row 3: 8.30Input 2 :2 26.8 1.25.6 8.9Output 2 :Average of each row:Row 1: 4.00Row 2: 7.25Input 3 :5 52.2 3.8 4.3 5.8 9.26.7 7.1 8.8 9.2 10.711.7 12.8 13.7 14.3 15.316.2 17.4 18.2 19.2 20.121.3 22.7 23.4 24.3 25.7Output 3 :Average of each row:Row 1: 5.06Row 2: 8.50Row 3: 13.56Row 4: 18.22Row 5: 23.48
Solution
The problem statement is asking to create a program that processes a 2D array. The program should include functions to calculate the average value of each row in a 2D array. The program should consist of several functions:
-
calculateRowAverage(cols, row): This function should calculate the average of a single row in a 2D array.
Similar Questions
Problem statementRaj is working on a data analysis project and needs help creating a program that processes a 2D array. This program includes functions to calculate the average value of each row in a 2D array. The program should consist of several functions:calculateRowAverage(cols, row): Calculates the average of a single row in a 2D array.calculateAverages(rows, cols, arr, averages): Computes and stores the averages for each row in the 2D array.displayAverages(rows, averages): Displays the row number and its average value.Input format :The first line of input consists of two integers, rows and cols, representing the dimensions of the 2D array.The second line of input consists of the elements arr[i] of the 2D array, where each element is a double.Output format :The output displays the average value of each row as a double datatype value, rounded off two decimal points in the specified format:Average of each row:Row 1: [row1_avg]Row 2: [row2_avg]Row 3: [row3_avg]Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1 ≤ rows and cols ≤ 51.0 ≤ arr[i] ≤ 5.0Max_Rows and Cols = 100Sample test cases :Input 1 :3 31.7 2.9 3.54.2 5.7 6.87.2 8.1 9.6Output 1 :Average of each row:Row 1: 2.70Row 2: 5.57Row 3: 8.30Input 2 :2 26.8 1.25.6 8.9Output 2 :Average of each row:Row 1: 4.00Row 2: 7.25Input 3 :5 52.2 3.8 4.3 5.8 9.26.7 7.1 8.8 9.2 10.711.7 12.8 13.7 14.3 15.316.2 17.4 18.2 19.2 20.121.3 22.7 23.4 24.3 25.7Output 3 :Average of each row:Row 1: 5.06Row 2: 8.50Row 3: 13.56Row 4: 18.22Row 5: 23.48
Single File Programming QuestionProblem StatementMithun is developing a program for a data collection tool that allows the user to input a series of positive integers until they enter a negative value. The program should dynamically allocate memory for an integer array to store these numbers using the new operator. The program should then calculate and display the sum and average of the entered integers. Write a program to accomplish this task.Note: This kind of question will help in clearing HCL recruitment.Input format :The input consists of positive integers separated by a space. It continues until a negative value is entered.Output format :The first line of the output displays the entered numbers.The second line displays the sum of the numbers.The third line displays the average of the entered numbers.Refer to the sample output for formatting specifications.Code constraints :numbers > 0Maximum number <=100Sample test cases :Input 1 :1 2 3 4 5 6 -1Output 1 :Numbers entered: 1 2 3 4 5 6 Sum of entered numbers: 21Average of entered numbers: 3.50Input 2 :10 20 30 40 50 60 70 80 90 100 -4Output 2 :Numbers entered: 10 20 30 40 50 60 70 80 90 100 Sum of entered numbers: 550Average of entered numbers: 55.00Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Single File Programming QuestionProblem statementJerzy, a devoted mathematician, is looking to develop a program that addresses a unique challenge involving prime numbers and 2D arrays.The objective of this program is to efficiently identify prime numbers within a 2D array and calculate their cumulative sum.The program will include two key functions:isPrime(num): This function will assess whether a given integer num is a prime number.sumOfPrimes(rows, cols, arr): This function will calculate and return the sum of all prime numbers found within a 2D array arr, which has dimensions specified by rows and cols. Input format :The first line of input consists of two integers r and c, representing the number of rows and columns in the 2D array.The next r lines of input consist of c integers each, separated by space, representing the elements of the 2D array.Output format :The output displays a single integer, representing the sum of all prime numbers in the given 2D array.Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1 ≤ r , c ≤ 101 ≤ elements ≤ 100Sample test cases :Input 1 :2 32 3 76 9 8Output 1 :12Input 2 :3 42 3 4 57 8 9 1011 12 13 14Output 2 :41Input 3 :5 52 3 4 5 96 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 24 25Output 3 :100Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Given a matrix, write a program to calculate the average of all its elements.Input:The input consists of two integers, m and n, representing the number of rows and columns in the matrix, respectively. This is followed by m lines, each containing n integers representing the elements of the matrix.Output:Print the average of all elements in the matrix.
Single File Programming QuestionProblem StatementJamie is managing a school and is looking to find out the number of students in the class based on the sum of their scores and the average score.He wants to design a program that takes the average score and sum of scores as input and outputs the calculated number of students in the class using pointers.Input format :The first line of input consists of an integer value n, representing the sum of scores.The second line of input consists of a floating-point value f, representing the average score.Output format :The output displays the calculated number of students in the class.Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1 ≤ n ≤ 1051.0 ≤ f ≤ 100.0Sample test cases :Input 1 :187575.45Output 1 :24Input 2 :20010.25Output 2 :19Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.Marks : 10Negative Marks : 0WhitelistSet 1:*
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.