Write a C++ program to find maximum of two integer numbers and two float numbers by using function template.
//Note: If you are not using Borland or Turbo C then add the following line after header files :
//using namespace std;
#include<conio.h>
#include<iostream.h>
template <typename x> //template
x big (x a,x b)
{
if(a>b)
{
return(a);
}
else
return(b);
}
int main()
{
int a,b,x,y;
cout<<"\nEnter 1st integer number : ";
cin>>a;
cout<<"\nEnter 2nd integer number : ";
cin>>b;
cout<<"\nEnter 1st float number : ";
cin>>x;
cout<<"\nEnter 2nd float number : ";
cin>>y;
cout<<"Maximum integer number is : "<<big<int>(a,b)<<endl;
cout<<"Maximum float number is : "<<big<float>(x,y);
getch();
return(0);
}
-
Next Create a class Clock that contains integer data members as hours, minutes and seconds. Write a C++ program to perform following member functions: void setclock(int, int, int ) to set the initial time of clock object. void showclock() to display the time in hh:min:sec format. Write a function tick( ) which by default increment the value of second by 1 or according to user specified second. The clock uses 24 hours format.
-
Previous Create a C++ class Sumdata to perform following functions: int sum( int, int) - returns the addition of two integer arguments. float sum(flaot, float, float) - returns the addition of three float arguments. int sum( int [ ] ,int) - returns the sum of all elements in an array of size 'n'.
0 Comments