Answer to Question #236110 in C++ for SOM

Question #236110

Write the function for the following operations, using appropriate OOP concept such that the code is minimized.

Find product of two numbers

Find product of three numbers.

Find product of four numbers


1
Expert's answer
2021-09-16T18:45:22-0400
#include<iostream>
using namespace std;
class Product{
	public:
		void product(int a, int b){
			cout<<"The product of "<<a<<"  and  "<<b<<"  is: "<<a * b<<endl;
		}
		void product(int a, int b, int c){
			cout<<"The product of "<<a<<"  , "<<b<<" and "<<  c<< " is: "<<a * b * c<<endl;
		}
	
		void product(int a, int b, int c, int d){
			cout<<"The product of "<<a<<"  , "<<b<<",  "<<  c<< " and "<< d<<" is:  "<<a * b * c * d<<endl;
		}
};
int main(){
	Product p;
	p.product(3,7);
	p.product(3,7,8);
	p.product(9,10,45,78);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS