Design a template function to find least amount of purchase from the quoted tender document. [Note: Amount in lakhs]
#include <iostream>
using namespace std;
template <typename T>
T leastAmount(T arr[],T size) {
  int min=arr[0];
  for (int i=0;i<size;i++){
    if (arr[i]<min){
      min=arr[i];
    }
  }
  return min;
}
int main()
{
  int amounts[7]={200,145,300,456,234,100,457};
  int minAmount=leastAmount<int>(amounts,7);
  cout<<"The least amount of purchase is: "<<minAmount<<" lakhs";
  return 0;
}
Comments
Leave a comment