write a c++ program that can take either two integers or two floating point numbers and outputs the smallest and greatest number using class,function overloading
Answers
Answered by
2
#include <iostream>
using namespace std;
int smallest(int a, int b)
{
return (a<b) ? a:b;
}
float smallest(float a, float b)
{
return (a<b) ? a: b;
}
int main()
{
cout<<smallest(10,20)<<endl;
cout<<samllest(10.2,20.2)<<endl;
return 0;
}
using namespace std;
int smallest(int a, int b)
{
return (a<b) ? a:b;
}
float smallest(float a, float b)
{
return (a<b) ? a: b;
}
int main()
{
cout<<smallest(10,20)<<endl;
cout<<samllest(10.2,20.2)<<endl;
return 0;
}
nandhinimouli:
Mark me as brainiest if u find it more useful
Answered by
0
#include <iostream.h>
class Smaller {
public:
int smaller(int x, int y)
{
return x < y ? x : y;
}
float smaller(float x, float y)
{
return x < y ? x : y;
}
}
void main()
{
int x = 45;
int y = 17;
cout << Smaller().smaller(x, y) << endl;
float p = 7.443f; float q = 11.11111f; cout << Smaller().smaller(p, q) << endl;
getch();
}
class Smaller {
public:
int smaller(int x, int y)
{
return x < y ? x : y;
}
float smaller(float x, float y)
{
return x < y ? x : y;
}
}
void main()
{
int x = 45;
int y = 17;
cout << Smaller().smaller(x, y) << endl;
float p = 7.443f; float q = 11.11111f; cout << Smaller().smaller(p, q) << endl;
getch();
}
Answered by
0
Similar questions