C++ Program to Find Minimum Value using Function Overloading

C++ Program to Find Minimum Value using Function Overloading, C++ Program to Find Minimum Value using Function Overloading

Write a program to find the minimum value among the inputs given. Your program should contain two functions with return type as int min(int, int); and int min(int, int, int); i.e. the first function takes two arguments and the second one three. Use the concept ofFunction Overloading.

C++ Program to Find Minimum Value using Function Overloading

Source Code
#include<iostream.h>
#include<conio.h>
int min(int, int);
void main()
{
  int a,b,c,d;
  cout<<"Enter Number:";
  cin>>a>>b>>c>>d;
  cout<<"Minimum no="<<min(min(a,b),min(c,d));
  getch();
}
int min(int j, int k)
{
  return((j<k)?j:k);
}
Output:
Enter Number:3
4
5
6
Minimum no=3

Source Code
#include<iostream.h>
#include<conio.h>
int min(int, int, int);
void main()
{
  int a,b,c,d,e,f;
  cout<<"Enter Number:";
  cin>>a>>b>>c>>d>>e>>f;
  cout<<"Minimum no="<<min(min(a,b),min(c,d),min(e,f));
  getch();
}
int min(int j, int k, int l)
{
  if(j<k && k<l && l<j)
  return j,k,l;
}
Output:
Enter Number:3
4
5
6
5
6
Minimum no=3
  

You May Also Like...

Socialize with Us