Write a program W.A.P. use of function template to evaluate the minimum of two values of any data types


 

/* Write a program W.A.P. use of function template to evaluate the minimum of two values of any data types*/

#include<iostream.h>

#include<conio.h>

template<class t>

t min(t a,t b)

{

return(a<b)?a:b;

}

void main()

{

clrscr();

int x,y;

cin>>x>>y;

cout<<“min of integer value is=”<<min(x,y);

float p,q;

cin>>p>>q;

cout<<“min of float value is=”<<min(p,q);

char c1,c2;

cin>>c1>>c2;

cout<<“min of char value is=”<<min(c1,c2);

getch();

}

/* output:

5 10

min of integer value is=5

1.5 2.0

min of float value is=1.5

r h

min of char value is=h*/

Related Posts

Comments are closed.