Answer to Question #193910 in C++ for ram@2002

Question #193910

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


1
Expert's answer
2021-05-16T00:30:40-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog