Soru
What should be typed to missing code sections in the following C++prc output properly? #include <iostream> /'missing code - I"/ int main() double x,y, is cout "Enter three numbers: cin >>x>>y >) 1; cout <<"The output is ' (c 41(x,y,z) << endl; return 0; , /missing code II" if (b (a) 88 ) return b; else if c (a) return c; else return a; ) I'missing code -II double flidouble a double b. couble C) b. I'missing code -1"double fl(couble, double double) I'musing code -11 double fil couble a double b double c) in missing code -17 couble fl couble, double double
Çözüm
4.1182 Voting
İlker
Gelişmiş · 1 yıl öğretmeniUzman doğrulaması
Cevap
To output properly, the missing code sections in the given C++ program should be filled as follows:<br /><br />```cpp<br />#include <iostream><br /><br />double f(double a, double b, double c) {<br /> if (b > a) {<br /> return b;<br /> } else if (a > c) {<br /> return c;<br /> } else {<br /> return a;<br /> }<br />}<br /><br />int main() {<br /> double x, y, z;<br /> cout << "Enter three numbers: ";<br /> cin >> x >> y >> z;<br /> cout << "The output is " << f(x, y, z) << endl;<br /> return 0;<br />}<br />```<br /><br />Explanation:<br />1. The function `f` takes three `double` parameters `a`, `b`, and `c`. It returns the largest of the three values.<br />2. In the `main` function, the user is prompted to enter three numbers, which are stored in `x`, `y`, and `z`.<br />3. The function `f` is called with `x`, `y`, and `z` as arguments, and the result is printed to the console.
Derecelendirmek için tıklayın: