Answer to Question #193344 in C++ for Sivasurya

Question #193344

Design a template function to find least amount of purchase from the quoted tender document. [Note: Amount in lakhs]


1
Expert's answer
2021-05-14T16:07:59-0400
#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;
}

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