Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Name : Aditya S Gangurde
- Roll no : 23
- Practical No : 2
- Write a C++ program that illustrates the concept of Function over loading.
- Write a program to multiply two number.
- multiply should be function.
- 1) multiply two integer values
- 2) multiply two double values
- 3) multiply three values i,e two integer values and one double
- value
- #include <iostream>
- using namespace std;
- int multiply(int a, int b);
- double multiply(double x, double y);
- double multiply(int x, int y , double z);
- int main(){
- int a , b , n , s ;
- double c , d , p;
- cout<<"Enter two integer numbers: ";
- cin>>a>>b;
- cout<<"Enter two double numbers: ";
- cin>>c>>d;
- cout<<"Enter two integer and one double number: ";
- cin>>n>>s>>p;
- multiply(a,b);
- multiply(c,d);
- multiply(n,s,p);
- return 0;
- }
- int multiply(int a, int b)
- {
- int mult1 = a*b ;
- cout<<"Result of multiplication of two integer numbers :: "<< endl;
- }
- double multiply(double x, double y)
- {
- double mult2 = x*y ;
- cout<<"Result of multiplication of two double numbers :: "<< endl;
- }
- double multiply(int x, int y , double z)
- {
- double mult3 = x*y*z ;
- cout<<"Result of multiplication of two integer numbers and one double number :: "<< endl;
- }
- *****OUTPUT*****
- Enter two integer numbers: 2
- 3
- Enter two double numbers: 2.2
- 3.3
- Enter two integer and one double number: 2
- 3
- 2.3
- Result of multiplication of two integer numbers :: 6
- Result of multiplication of two double numbers :: 7.26
- Result of multiplication of two integer numbers and one double number :: 13.8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement