Program1



Write a program to create a function template for finding maximum value contained in an array.


  

#include<iostream.h>
#include<conio.h>
template <class t>

void findmax(t a[5])
{
  t temp=0.0;
  for(int i=0;i<=5;i++)
  {
    if(a[i]>temp)
    {
      temp=a[i];
     }
   }
      cout<<"Max is"<<temp;
 }
void main()
{
  clrscr();
  cout<<"\n Integer array";
  int a[]={3,5,2,9,1};
  findmax(a);

  cout<<"\n Float array";
  float a1[]={3.1,5.2,2.3,9.1,1.9};
  findmax(a1);
  getch( );
}