Question

In: Computer Science

In C++ please. 7. Provided that c1, c2 and c3 are of appropriate ranges. Use transform()...

In C++ please.

7. Provided that c1, c2 and c3 are of appropriate ranges. Use transform()
   algorithm so that it copies the larger of the corresponding elements
   from c1 and c2 to c3. That is, if

   c1 = {1, 2, 3, 4, 5} and   c2 = {5, 4, 3, 2, 1}

   then c3 should become c3={5, 4, 3, 4, 5}

Solutions

Expert Solution

7). ANSWER :

GIVENTHAT :

C++ PROGRAM :

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int compare(int a, int b){
if(a>b){
return a;
}
else{
return b;
}
}
int main()
{
int c1[]={1,2,3,4,5};
int c2[]={5,4,3,2,1};
int n=sizeof(c1)/sizeof(c1[0]); //to get number of elements in array c1
int c3[n];
//transform(Iteretor inputBegin1,Iteretor inputEnd1,Iteretor inputBegin2,Iteretor OutputBeign,binary_opertion)
transform(c1,c1+n,c2,c3,compare);
for(int i=0;i<n;i++){
std::cout << c3[i] << " ";
}
return 0;
}


Related Solutions

Calculate the values "c1, c2, c3, c4, c5" with superposition 6(c1) – (c3)=50 -3(c1) + 3(c2)=0...
Calculate the values "c1, c2, c3, c4, c5" with superposition 6(c1) – (c3)=50 -3(c1) + 3(c2)=0 9(c3) – (c2)= 160 -(c2) – 8(c3) – 2(c5) + 11(c4)=60 -3(c1) – (c2) + 4(c5)=10
U(C1, C2, C3, C4, C5) = C1∙C2∙C3∙C4∙C5 As a mathematical function, does U have a maximum...
U(C1, C2, C3, C4, C5) = C1∙C2∙C3∙C4∙C5 As a mathematical function, does U have a maximum or minimum value? What values of Ci correspond to the minimum value of U? What values of Ci correspond to the maximum value of U? Do these values of Ci make sense from an economic standpoint? Now let us connect the idea of economic utility to actual dollar values. To keep the values more manageable, we will use household income rather than the entire...
U(C1, C2, C3, C4, C5) = C1∙C2∙C3∙C4∙C5 As a mathematical function, does U have a maximum...
U(C1, C2, C3, C4, C5) = C1∙C2∙C3∙C4∙C5 As a mathematical function, does U have a maximum or minimum value? What values of Ci correspond to the minimum value of U? What values of Ci correspond to the maximum value of U? Do these values of Ci make sense from an economic standpoint? Now let us connect the idea of economic utility to actual dollar values. To keep the values more manageable, we will use household income rather than the entire...
. If it has the following solution: y= c1 + c2 cos (2x) + c3 sin...
. If it has the following solution: y= c1 + c2 cos (2x) + c3 sin (2x) + c4 e3x Then:
Consider the following cash flows: C0 / C1/ C2 /C3 /C4 ? $ 27 / +...
Consider the following cash flows: C0 / C1/ C2 /C3 /C4 ? $ 27 / + $ 24 / + $ 24 / + $ 24 / ? $ 46 a. Which two of the following rates are the IRRs of this project? (You may select more than one answer. Single click the box with the question mark to produce a check mark for a correct answer and double click the box with the question mark to empty the box...
Please do the Projetion of Newman (C2 – C3) and the Projetion of Newman (C2 –...
Please do the Projetion of Newman (C2 – C3) and the Projetion of Newman (C2 – C3) of Butane and the 2-metilpropane Projection of Newman (C2 –C3)                             Projection of Newman (C2 –C3)
Cash flows of Project A and B are as following: Project C0 C1 C2 C3 C4...
Cash flows of Project A and B are as following: Project C0 C1 C2 C3 C4 C5 A -9000 2000 3000 4000 5000 6000 B -11000 2000 3000 4000 5000 6000          Compute the payback periods for the following two projects.          Payback period for A = _________ years; for B __________years          If the discount rate is 10%, what is the discounted payback period?          Discounted payback period for A=_________ years; for B __________years
Here are the cash flows for two mutually exclusive projects: Project C0 C1 C2 C3 A...
Here are the cash flows for two mutually exclusive projects: Project C0 C1 C2 C3 A −$ 23,000 +$ 10,120 +$ 10,120 +$ 10,120 B − 23,000 0 0 + 31,050 What is the IRR of each project? (Round your answers to 2 decimal places.)
You have three capacitors: C1 = 1500. μF, C2 = 2400. μF, and C3 = 3600....
You have three capacitors: C1 = 1500. μF, C2 = 2400. μF, and C3 = 3600. μF. Find Ceq for a) all in series b) all in parallel c) c1 and c2 are in parallel and c3 in series with them d) c2 and c3 in parallel and R1 in series with them, e)c1 and c3 in parallel and c2 in series with them. f) For one of the three arrangements where only two of the caps are connected in...
Here are the cash flows for two mutually exclusive projects: Project C0 C1 C2 C3 A...
Here are the cash flows for two mutually exclusive projects: Project C0 C1 C2 C3 A −$ 21,800 +$ 9,592 +$ 9,592 +$ 9,592 B − 21,800 0 0 + 29,430 What is the IRR of each project? (Round your answers to 2 decimal places.) PRoject A % Project B %
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT