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 is oppes

2 Answers  


why the memory allocated with new cant be freed using free()

2 Answers  


What is object in oop?

0 Answers  


what is different between oops and c++

0 Answers   IIT,


When is it necessary to use member-wise initialization list in C++?

2 Answers   Adobe,






What do you mean by binding of data and functions?

3 Answers  


What is the difference between abstraction and polymorphism?

0 Answers  


How to Increment the value of the empid E001 for each and every employee by using the programe?

1 Answers   Accenture,


class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash

0 Answers  


How Do you Code Composition and Aggregation in C++ ?

3 Answers   IBM, NET,


What is encapsulation and abstraction? How are they implemented in C++?

0 Answers   Agilent, ZS Associates,


What is protected in oop?

0 Answers  


Categories