Advertisement
adiee

Untitled

Jun 3rd, 2021
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. Name : Aditya S Gangurde
  2. Roll no : 23
  3. Practical No : 2
  4.  
  5.  
  6. Write a C++ program that illustrates the concept of Function over loading.
  7. Write a program to multiply two number.
  8. multiply should be function.
  9. 1) multiply two integer values
  10. 2) multiply two double values
  11. 3) multiply three values i,e two integer values and one double
  12. value
  13.  
  14.  
  15. #include <iostream>
  16. using namespace std;
  17. int multiply(int a, int b);
  18. double multiply(double x, double y);
  19. double multiply(int x, int y , double z);
  20. int main(){
  21. int a , b , n , s ;
  22. double c , d , p;
  23. cout<<"Enter two integer numbers: ";
  24. cin>>a>>b;
  25. cout<<"Enter two double numbers: ";
  26. cin>>c>>d;
  27. cout<<"Enter two integer and one double number: ";
  28. cin>>n>>s>>p;
  29. multiply(a,b);
  30. multiply(c,d);
  31. multiply(n,s,p);
  32. return 0;
  33. }
  34. int multiply(int a, int b)
  35. {
  36. int mult1 = a*b ;
  37. cout<<"Result of multiplication of two integer numbers :: "<< endl;
  38. }
  39. double multiply(double x, double y)
  40. {
  41. double mult2 = x*y ;
  42. cout<<"Result of multiplication of two double numbers :: "<< endl;
  43. }
  44. double multiply(int x, int y , double z)
  45. {
  46. double mult3 = x*y*z ;
  47. cout<<"Result of multiplication of two integer numbers and one double number :: "<< endl;
  48. }
  49.  
  50. *****OUTPUT*****
  51.  
  52. Enter two integer numbers: 2
  53. 3
  54. Enter two double numbers: 2.2
  55. 3.3
  56. Enter two integer and one double number: 2
  57. 3
  58. 2.3
  59. Result of multiplication of two integer numbers :: 6
  60. Result of multiplication of two double numbers :: 7.26
  61. Result of multiplication of two integer numbers and one double number :: 13.8
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement