Write a program to create a function template for finding maximum value contained in an array.
CODING:
#include<iostream.h>
#include<conio.h>
template <class t>
t max(t a,t b)
{
if(a>b)
return a;
else
return b;
}
void main()
{
clrscr();
cout<<max(5.5,6.6);
cout<<endl<<max(6,7);
cout<<endl<<max('a','b');
getch();
}
CODING:
#include<iostream.h>
#include<conio.h>
template <class t>
t max(t a,t b)
{
if(a>b)
return a;
else
return b;
}
void main()
{
clrscr();
cout<<max(5.5,6.6);
cout<<endl<<max(6,7);
cout<<endl<<max('a','b');
getch();
}
#include<iostream.h>
#include<conio.h>
template <class t>
t max(t a,t b)
{
if(a>b)
return a;
else
return b;
}
void main()
{
clrscr();
cout<<max(5.5,6.6);
cout<<endl<<max(6,7);
cout<<endl<<max('a','b');
getch();
}
Comments
Post a Comment