write a program in c++ to overload the function add (s1,s2)
where s1 and s2 are integers and floating point values.

Answers were Sorted based on User's Feedback



write a program in c++ to overload the function add (s1,s2) where s1 and s2 are integers and floati..

Answer / deepa mathur

include <iostream.h>

void add (int s1, int s2)
{
int s3;
s3= s1 + s2;
cout<<"sum of 2 no. is= "<< s3;
}

void add (float s1, float s2)
{
float s3;
s3 = s1 + s2;
cout<<" sum of 2 no. is= "<< s3;
}

void main
{
void add (int a, int b);
void add (float a, float b);
add(30, 20);
add (30.5, 56.7);
getch();
}

Is This Answer Correct ?    47 Yes 20 No

write a program in c++ to overload the function add (s1,s2) where s1 and s2 are integers and floati..

Answer / rose

include<iostream.h>

class overload
{
void add (int a, int b){
int c;
int c= a+b;
}
void add( float a,float b){
double c;
double c = a+b;}
}
void main()
{overload o = new overload();
o.add(10,20);
o.add(1.2,34.56);
getch();
}

Is This Answer Correct ?    14 Yes 10 No

write a program in c++ to overload the function add (s1,s2) where s1 and s2 are integers and floati..

Answer / vaibhav munde

#include<iostream.h>
#include<conio.h>
int add(int s1,int s2)
{
return(s1+s2);
}
float add(float a,float b)
{
return(a+b);
}
void main()
{
int s,s1,s2;
float a,b,c;
clrscr();
cout<<"\n Enter two integer number:";
cin>>s1>>s2;
s=add(s1,s2);
cout<<"Addition of two Integer number:"<<s;
out<<"\n Enter two float number:";
cin>>a>>b;
c=add(a,b);
cout<<"Addition of two Float number:"<<c;
getch();

}

Is This Answer Correct ?    12 Yes 8 No

write a program in c++ to overload the function add (s1,s2) where s1 and s2 are integers and floati..

Answer / shubham hajare

#include "stdafx.h"
#include<iostream>
#include<conio.h>
using namespace std;
class stud
{
public:
void add(int a,int b)
{
cout<<a+b;
}

void add(float a,float b)
{
cout<<a+b;
}

void add(int a,float b)
{
cout<<a+b;
}


};
void main()
{
stud a;
a.add(12,12);
a.add(1.2,1.2);
a.add(12,12.2);
_getch();
}

Is This Answer Correct ?    3 Yes 3 No

Post New Answer

More OOPS Interview Questions

What are the advantages of inheritance?

26 Answers   IBS, TCS,


What is the difference between an object and a class?

3 Answers  


Finding of the 4 larger (bigger) numbers from the list like{1245,4587,2145,1163,29987,65783.....}

1 Answers   Wipro,


What is oops concept with example?

0 Answers  


What is purpose of inheritance?

0 Answers  






what is difference between String s=new String("vali"); String s="vali"

1 Answers  


why function overloading is not called as pure polymorphism?

2 Answers  


What is new keyword in oops?

0 Answers  


what is difference between c++ language and java language

5 Answers  


What is methods in oop?

0 Answers  


When you define a integer it gets stored in which data structure?(Stack or a heap)

2 Answers   emc2,


What is the difference between inheritance and polymorphism?

0 Answers  


Categories