Showing posts with label minimum in array using templates. Show all posts
Showing posts with label minimum in array using templates. Show all posts

Wednesday, May 11, 2022

template func to find minimum in an array

 #include<iostream>

using namespace std;
template<class T>
T mini(T arr[],T size){
    T max=arr[0];
    for(int i=0;i<size;i++){
        if (arr[i]<max)
        {
            max=arr[i];
           
        }
       
    }
    return max;

}

int main(){
    int arr[]={1,2,3,4,1,100,0};
int min=mini<int>(arr,7);//we can use size using size of arr and size of first element division
cout<<min;
    return 0;
}

Software scope

 In software engineering, the software scope refers to the boundaries and limitations of a software project. It defines what the software wi...

Popular Posts