1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
salantis [7]
3 years ago
11

Question 4(10pt): sum of the max value found in each row Write a function maxSum that takes two parameters; a 2D integer array w

ith 10 columns, and the number of rows. The function must return the sum of the maximum value from each row.
Computers and Technology
1 answer:
mario62 [17]3 years ago
5 0

Answer:

Following is the program in c++ language  

#include <iostream> // header file

using namespace std; // namespace

int maxSum(int ar[][10],int r) // function definition of  maxsum

{

  int s=0; // varaible declaration

  for(int k=0;k<r;k++)// iterating the loop

  {

      int maximum=ar[k][0]; //finding the maximum value

      for(int k2=0;k2<10;k2++)// iterating the loop

      {

          if(maximum<ar[k][k2]) // check the condition

          {

            maximum=ar[k][k2];   // storing the value in the maximum variable

          }

           }

       s=s+maximum;//adding maximum value to the sum

  }

  return s; // return the sum

}

int main() // main function

{

  int ar[][10]={{5,2,8,-8,9,9,8,-5,-1,-5},{4,1,8,0,10,7,6,1,8,-5}}; // initilaized array

  cout<<"sum of maximum value:";

  int t=maxSum(ar,2); // function calling

  cout<<t; // display the maximum value

}

Output:

sum of maximum value:19

Explanation:

Following are the description of Program  

  • The main method declared and initialized an array ar with the column value 10.
  • After that call the method maxsum .The control will move to the function definition of maxsum.
  • In the function header of maxisum there are two value i.e array "ar" and "r".
  • In this function definition, we adding the maximum value to the sum and return the variable "s".
  • In the main function, we print the value.
You might be interested in
A palindrome is a string that reads the same from left to right and from right to left. Design an algorithm to find the minimum
stepladder [879]

Answer:

Explanation:

The following code is written in Python. It is a recursive function that tests the first and last character of the word and keeps checking to see if each change would create the palindrome. Finally, printing out the minimum number needed to create the palindrome.

import sys

def numOfSwitches(word, start, end):

   if (start > end):

       return sys.maxsize

   if (start == end):

       return 0

   if (start == end - 1):

       if (word[start] == word[end]):

           return 0

       else:

           return 1

   if (word[start] == word[end]):

       return numOfSwitches(word, start + 1, end - 1)

   else:

       return (min(numOfSwitches(word, start, end - 1),

                   numOfSwitches(word, start + 1, end)) + 1)

word = input("Enter a Word: ")

start = 0

end = len(word)-1

print("Number of switches required for palindrome: " + str(numOfSwitches(word, start, end)))

3 0
2 years ago
Win10如何删除自己添加的环境变量?...............
Paha777 [63]

Answer:

方法/步骤

右键单击以选择此计算机,然后有一个菜单来选择属性。

选择后,打开属性面板以找到我们的高级系统设置。

打开后,我们在系统设置下找到高级设置。

打开后,我们看到下面有一个环境变量选项。

打开后,我们在右下角看到一个删除选项。

单击删除到,在右下角后单击删除,然后单击确定的选项。 ...

本文未经授权摘自百度经验

8 0
2 years ago
What term is used to describe a list of security policies that is associated with an object?
Artemon [7]

Answer:

An Access control list (ACL) is used to describe a list of security policies that is associated with an object

5 0
3 years ago
Computer that process digital as well as analogue signals​
Nuetrik [128]

Answer:

The answer is hybrid computer coz it is the combination of both analog and digital computers

Explanation:

hope it helps

good day

5 0
3 years ago
When a table is displayed in datasheet view, each column represents a select one:
Ksivusya [100]
The answer a. record in the table.
5 0
3 years ago
Other questions:
  • What technology process would help you access files at all times?
    11·1 answer
  • Although heart rate increases and decrease depending upon activity level on average a typical person heart rate is about _____ b
    10·1 answer
  • Which of the following commands would instruct OSPF to advertise ONLY the 192.168.10.0/24 network in Area 0?
    13·1 answer
  • What is the name for a hardcoded value entered into a formula ?
    8·2 answers
  • You are troubleshooting a client connectivity problem on an Ethernet network. The client system has intermittent connectivity to
    9·1 answer
  • For the recursive method below, list the base case and the recursive statement, then show your work for solving a call to the re
    8·1 answer
  • In which of the following phases of filmmaking would a production team be focused on the
    10·2 answers
  • Why are formulas used in spreadsheets?
    10·1 answer
  • Where can formatting features be found ?! Need help asp !‍♀️
    9·1 answer
  • FILL IN THE BLANK.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!