Computer Science, asked by umsa, 1 year ago

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 nandhinimouli
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;
}
 

nandhinimouli: Mark me as brainiest if u find it more useful
AvmnuSng: Also use class, that will be nice as question asks for implementation of class and function overloading
Answered by Anonymous
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();
 }

AvmnuSng: are you a regular programmer ??
Anonymous: no
AvmnuSng: check out my code, once... if u are answering, must answer the exact thing, questioner asking....
AvmnuSng: and there are rules for syntax and other thing, u must follow those rules
Answered by AvmnuSng
0
I've attached the code, check it out.....
Attachments:
Similar questions