In: Computer Science
Write an overloaded function of function area with 3 (float) parameters. This function should calculate and print out the product of the 3 parameters.
// Write an overloaded function of function area with 3 (float) parameters void area(float n1, float n2, float n3) { // This function should calculate and print out the product of the 3 parameters. cout << "The product is " << n1*n2*n3 << endl; }
#include <iostream> using namespace std; void area(double radius) { const double pi = 3.14; cout << "The area of the circle is: " << pi*radius*radius << endl; } void area(double width, double length) { cout << "The area of the rectangle is: " << width * length << endl; } // Write an overloaded function of function area with 3 (float) parameters void area(float n1, float n2, float n3) { // This function should calculate and print out the product of the 3 parameters. cout << "The product is " << n1*n2*n3 << endl; } int main() { double radius = 5.5; cout << "Radius: " << radius << endl; area(radius); double width = 5, length = 7; cout << "Width: " << width << ", Length: " << length << endl; area(width, length); float n1 = 3, n2 = 2, n3 = 7; cout << "numbers are: " << n1 << ", " << n2 << " and " << n3 << endl; area(n1, n2, n3); return 0; }