1 answer

Write a function named midvalue that is passed three unique int values and returns the one...

Question:

Write a function named midvalue that is passed three unique int values and returns the one that is in the middle. Thus, midvalue(5,28,14) returns 14. ( in c++)


Answers

Here I am providing the answer for the above question:

Code:

#include <bits/stdc++.h>
using namespace std;
  
int midvalue(int , int , int ); //funtion declaration
  
int main()
{
cout <<"midvalue:"<<midvalue(5,28,14);  
return 0;
}

int midvalue(int x, int y, int z)
{
//if y is greater than x and less then z (or) y is greater than z and less than x
if ((x < y && y < z) || (z < y && y < x))
return y;
//if x is greater than y and less then z (or) x is greater than z and less than y
else if ((y < x && x < z) || (z < x && x < y))
return x;
else
return z;
}
Screenshot of code:

#include <bits/stdc++.h> using namespace std; int midvalue(int , int , int ); int main() cout <<midvalue:<<midvalue(5,28,14

Output:

midvalue:14

Hoping that the above answer will help you...Thank you...

.

Similar Solved Questions

1 answer
RiverRocks, whose WACC is 12.7%, is considering an acquisition of Raft Adventures (whose WACC is 14.8%)....
RiverRocks, whose WACC is 12.7%, is considering an acquisition of Raft Adventures (whose WACC is 14.8%). The purchase will cost $103.1 million and will generate cash flows that start at $15.1 million in one year and then grow at 4.2% per year forever. What is the NPV of the acquisition?...
1 answer
Pates Corp. issued 11,000 shares of no-par common stock for $14 per share. Read the requirements...
Pates Corp. issued 11,000 shares of no-par common stock for $14 per share. Read the requirements Requirement 1a. Record issuance of the stock if the stock is true no-par stock. (Record debits first, then credits Select the explanation on the last line of the journal entry table Date Accounts and Exp...
1 answer
You have 0.500 moles of lead nitrate and 1.50 moles of potassium chloride available for this...
You have 0.500 moles of lead nitrate and 1.50 moles of potassium chloride available for this reaction. use stoichiometric ratios to determine the limiting and excess reagents for this reaction (in moles), by calculating the moles of the PbCl2 product (precipitate) formed. show all your work. Pb(No3)...
1 answer
Can someone show me how to do this and explain this to me 20. Rank the...
can someone show me how to do this and explain this to me 20. Rank the following in decreasing order of leaving group ability. C šo cu do c OH I III IV I > III > IV > II I > III > II > IV III > II > I > IV II > I > III > IV...
1 answer
In 5-6 sentences explain the following What are interrupts? How are they managed? (Your answer should...
In 5-6 sentences explain the following What are interrupts? How are they managed? (Your answer should include interrupt lines and ISRs) What is a system call? How is it different from a regular library function call?...
1 answer
. Suppose Abdulrahman Plan to borrow a loan of SAR 120,000 now and will repay it...
. Suppose Abdulrahman Plan to borrow a loan of SAR 120,000 now and will repay it in 10 equal annual installments. If the bank charges 10% interest, what would be the amount of the annual installment?...
1 answer
DDJ just issued an 8-year bond. The bond makes semi-annual coupon payments based on annual coupon...
DDJ just issued an 8-year bond. The bond makes semi-annual coupon payments based on annual coupon rate of 6%. If the bond is trading at $1,125.25, what is the bond’s yield to maturity? Question 19 options: 2.07% 2.01% 5.14% 5.97% None of the above...
1 answer
An n x n matrix is called nilpotent if Ak = 0 (the zero matrix) for...
An n x n matrix is called nilpotent if Ak = 0 (the zero matrix) for some positive integer k. (a) Suppose A is a nilpotent nxn matrix. Prove that is an eigenvalue of A. (b) Must O be the only eigenvalue of A? Either prove or give a counterexample,...
1 answer
Draw a planned aggregate expenditure curve for an economy where autonomous expenditure is $200 billion and...
Draw a planned aggregate expenditure curve for an economy where autonomous expenditure is $200 billion and the marginal propensity to consume is equal to 0.50. Plot values for Actual Aggregate Expenditure' of $100, $200, $300, $400, $500, and $600. Instructions: Use the graphing tool to draw the...
1 answer
1. (i) In a circuit, the voltage is given by: Vs (t) 12 cos(50t10) V (a)...
1. (i) In a circuit, the voltage is given by: Vs (t) 12 cos(50t10) V (a) What is the amplitude of the voltage? (b) What is the phase of the voltage? (c) What is the angular frequency (radians/sec.) of the voltage? (d) What is the frequency (in cycles/sec.) of the voltage? (e) Determine vs (t) at tim...
1 answer
6. The drawing shows a positive charge (g) and a negative charge (a) fixed to a...
6. The drawing shows a positive charge (g) and a negative charge (a) fixed to a circle. At the center of the circle they produce a net electric field that is directed along the horizontal axis. Determine the ratio ql/n of the charges if α-270° and β-550°. 91/...
1 answer
Please help Rogers Company reported net income of $36,642 for the year. During the year, accounts...
please help Rogers Company reported net income of $36,642 for the year. During the year, accounts receivable increased by $6,176, accounts payable decreased by $3,079, and depreciation expense of $5,776 was recorded. Net cash provided by operating activities under the indirect method for the yea...
1 answer
CN as at December 31, 2019, the maximum potential liability under these guarantee instruments was $742...
CN as at December 31, 2019, the maximum potential liability under these guarantee instruments was $742 million (2018 - $707 million), of which $681 million (2018 - $659 million) related to other employee benefit liabilities and workers' compensation and $61 million (2018 - $48 million) related t...
1 answer
(LO 6) E4-7 (Income Statement Items) Certain account balances follow for Vincenti Products Corp.: Rent revenue...
(LO 6) E4-7 (Income Statement Items) Certain account balances follow for Vincenti Products Corp.: Rent revenue $  8,500 Sales discounts $ 17,800 Interest expense 2,700 Selling expenses 79,400 Beginning retained earnings 114,400 Sales revenue 490,000 E...
1 answer
Hi there, may i know how to construct the boolean expresion for this vacuum cleaner. Thanks in ad...
Hi there, may i know how to construct the boolean expresion for this vacuum cleaner. Thanks in advance. An automatic vacuum cleaner is used to do house cleaning. There are four (3) variables involved in controlling the vacuum cleaner namely dusk, brightness and time. The vacuum cleaner will be ON wh...
1 answer
Consider the following functions: f(x) = V8 - 4 and g(x) Step 1 of 3: Find...
Consider the following functions: f(x) = V8 - 4 and g(x) Step 1 of 3: Find four ordered pairs that satisfy the function, f(x) = =4 Answer ). D]...