Thursday, 7 March 2019

CPP-EX4


WAP to class Maximum to perform following function as:
1)int min(int,int)
2)int min(int,int,int)
3)int min(int arr[],int n)

#include<iostream.h>
#include<conio.h>
class mindata
{
public:
void min(int,int);
void min(float,float,float);
void min(int arr[],int n);
};

void mindata::min(int a,int b)
{
if(a<b)
cout<<"\nminimum int number is\t"<<a;
else
cout<<"\nminimum int number is\t"<<b;
}

void mindata::min(float c,float d,float e)
{
if(c<d &&c<e)
cout<<"\nminimum float number is\t"<<c;
else if(d<c && d<e)
cout<<"\nminimum float number is\t"<<d;
else
cout<<"\nminimum float number is\t"<<e;
}

void mindata:: min(int g[],int n)
{
int a,i;
int smallest;

for(i=0;i<n;i++)
{
cout<<i;
cout<<"\t\t";
cin>>g[i];
}
smallest = g[0];

for (i=0; i<n; i++)
{
if (g[i]<smallest)
{
smallest=g[i];
}
}
cout<<"\nsmallest number in an array is \t"<<smallest;
}

void main()
{
int a,b,n,g[10];
float c,d,e;
clrscr();
mindata x,y,z;
cout<<"\nenter two integer  numbers\n";
cin>>a>>b;

x.min(a,b);
cout<<"\nenter three float number\n";
cin>>c>>d>>e;
y.min(c,d,e);

cout<<"\nhow many elements you want to enter \n";
cin>>n;
z.min(g,n);
getch();

}