Design a template function to find least amount of purchase from the quoted tender document. [Note: Amount in lakhs]
Runtime Input :
5
3
8
10
7
Output :
3 Lakhs
#include <iostream>
using namespace std;
template<typename T>
T Least(T* arr, int size){
T least = INT_MAX;
for(int i = 0; i < size; i++)
if(arr[i] < least) least = arr[i];
return least;
}
int main(){
int arr[5];
cout<<"Runtime input:\n";
for(int i = 0; i < 5; i++){
cin>>arr[i];
}
cout<<"Output:\n";
cout<<Least<int>(arr, 5)<<" Lakhs";
return 0;
}
Comments