Westonci.ca is the Q&A platform that connects you with experts who provide accurate and detailed answers. Our platform provides a seamless experience for finding reliable answers from a knowledgeable network of professionals. Experience the convenience of finding accurate answers to your questions from knowledgeable experts on our platform.
Sagot :
Functions that have one or more generic type parameters are referred to as generic functions.
How to write a generic function finds largest among the three values ?
Functions that have one or more generic type parameters are referred to as generic functions. They could be standalone functions or methods in a class or struct. A single generic declaration essentially declares a family of functions, with the sole difference being the actual type parameter's substitution with a different one.
#include <iostream>
using namespace std;
int main() {
double n1, n2, n3;
cout << "Enter three numbers: ";
cin >> n1 >> n2 >> n3;
check if n1 is the largest number
if(n1 >= n2 && n1 >= n3)
cout << "Largest number: " << n1;
check if n2 is the largest number
else if(n2 >= n1 && n2 >= n3)
cout << "Largest number: " << n2;
if neither n1 nor n2 are the largest, n3 is the largest
else
cout << "Largest number: " << n3;
return 0;
}
Output
Enter three numbers: 2.3 ,8.3 ,-4.2
Largest number: 8.3
To learn more about generic function refer to :
https://brainly.com/question/24304189
#SPJ1
Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.