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
Andrej [43]
3 years ago
11

github Portfolio Balances An investor opens a new account and wants to invest in a number of assets. Each asset begins with a ba

lance of o, and its value is stored in an array using 7-based indexing. Periodically, a contribution is received and equal investments are made in a subset of the portfolio. Each contribution will be given by investment amount, start index, end index. Each investment in that range will receive the contribution amount. Determine the maximum amount invested in any one investment after all contributions
Computers and Technology
1 answer:
OLEGan [10]3 years ago
6 0

The following code will be used to determine the maximum amount invested

<u>Explanation:</u>

long maxValue(int n, int rounds_rows, int rounds_columns, int into rounds)

{

   // Define the variable to store

   // the maximum amount invested.

   long max = 0;

   

   // Define an array of size n,

   // to store the n investments.

   long *investments = (long*)malloc(sizeof(long)*n);

   int i=0;  

   // Initially set all

   // the investments to 0.

   for(i=0;i<n;i++)

   {

       investments[i] = 0;

   }

   i=0;

   // Run the loop to

   // perform the rounds.

   while(i<rounds_rows)

   {

       // Get the left value

       // of the current round.

       int left = rounds[i][0];

       

       // Get the right value

       // of the current round.

       int right = rounds[i][1];

       // Get the contribution

       // for the current round.

       int contribution = rounds[i][2];

       // Since the user uses 1-based

       // indexing, subtract 1 from left

       // and right as the program uses

       // 0-based indexing. That is, the

       // investments in the array start

       // from 0 and not 1.

       right = right - 1;

       int j=0;

       // Run the loop to add the

       // contribution to all the investments

       // between left and right, both inclusive.

       for(j=left; j<=right; j++)

       {

           investments[j] += contribution;

       }

       i++;

   }

   // Traverse the investments array

   // to find the maximum element.

   max = investments[0];

   for(i=1; i<n;i++)

   {

       if(investments[i]>max)

       {

           max = investments[i];

       }

   }

   // Return the

   // maximum investment.

   return max;  

}

You might be interested in
3. When code tracing, why is it important to iteratively test parts of the program?
GenaCL600 [577]

Answer:

A. To isolate errors in the outcomes of code.

<em>Hope this helps! ^-^</em>

<em>-Isa</em>

7 0
3 years ago
According to the video, what is used to create computer programs?
Lena [83]
Its a or b. znskdbxkdb
8 0
3 years ago
Read 2 more answers
What are the real-life applications of coding?
oksian1 [2.3K]

Some example's of coding affecting real life:

  • Traffic Lights
  • Biometric Security
  • Robots used in factories. can work in extreme conditions.
  • Automatic Heater or Air Conditioner.
  • Expert Systems used in for Medical Use.
  • Smart Self Driving Cars
8 0
2 years ago
What is the advertising photographer’s main objective in creating an image?
iren2701 [21]
B. To sell it as a product
8 0
3 years ago
Djdjdjdjdjdjdjdjdjjdjdjdjdjdjdjdjdjdjdj
DanielleElmas [232]
Shorty a bad bleep .
7 0
3 years ago
Read 2 more answers
Other questions:
  • Given four values representing counts of quarters, dimes, nickels and pennies, output the total amount as dollars and cents. Out
    10·1 answer
  • Corey is an architect. What software does he most likely use to design houses? graphic software scheduling software CAD software
    10·2 answers
  • PLS ANSWER ASAP!
    9·1 answer
  • Enter key is also known as Return key. (True or false)
    13·2 answers
  • JAVA QUESTION::
    10·1 answer
  • Write a program that prompts the user to enter their name store this value in a variable called name Prompt the user for their c
    10·1 answer
  • Which of the following is the BEST reason to use cash for making purchases? everfi
    15·1 answer
  • How many grams are in 100 pounds?
    6·2 answers
  • One of the benefits of holding an investment for over a year rather than selling it in less than a year is that the
    14·2 answers
  • A large retail company hires several new joiners and would like to incorporate Virtual Reality (VR) into their onboarding proces
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!