write a program for function overloading?

Answers were Sorted based on User's Feedback



write a program for function overloading?..

Answer / nk

FYI

for overloading a function differing only by return type is
illegal (it is legal to use different a return type with a
different argument list, though) :

Is This Answer Correct ?    24 Yes 21 No

write a program for function overloading?..

Answer / vadivel

Function Overloading:
function overloading is nothing but same
function name but it passes the different arguments.

Is This Answer Correct ?    1 Yes 1 No

write a program for function overloading?..

Answer / sahana

//PROGRAM FOR FUNCTION OVERLOADING

#include<stdio.h>
#include<conio.h>
#include<iostream>
using namespace std;
void res(int,int,int); //FUNCTION DECLARATION
void res(float,int); //FUNCTION DECLARATION
void res(int,float,int); //FUNCTION DECLARATION
void res(float,float); //FUNCTION DECLARATION
void res(float,int,float); //FUNCTION DECLARATION
main()
{
int a,b,c;
cout<<"\t\t\t WELCOME TO FUNCTION OVERLOADING\n";
cout<<"\t\t\t*-------------------------------*\n";
res(a,b,c); //FUNCTION CALL
res(a,b); //FUNCTION CALL
res(a,b,c); //FUNCTION CALL
res(a,b); //FUNCTION CALL
res(a,b,c); //FUNCTION CALL
getch();
}

void res(int x,int y,int z) //FUNCTION DEFINITION
{
int sum;
cout<<"\n\nEnter 3 nos :\n\n";
cin>>x>>y>>z;
sum=x+y+z;
cout<<"\nResult = "<<sum;
}

void res(float x,int y) //FUNCTION DEFINITION
{
float rem;
cout<<"\n\nEnter 2 nos :\n\n";
cin>>x>>y;
rem=x-y;
cout<<"\nResult = "<<rem;
}

void res(int x,float y,int z) //FUNCTION DEFINITION
{
float pro;
cout<<"\n\nEnter 3 nos :\n\n";
cin>>x>>y>>z;
pro=x*y*z;
cout<<"\nResult = "<<pro;
}

void res(float x,float y) //FUNCTION DEFINITION
{
float quo;
cout<<"\n\nEnter 2 nos :\n\n";
cin>>x>>y;
quo=x/y;
cout<<"\nResult = "<<quo;
}

void res(float x,int y,float z) //FUNCTION DEFINITION
{
float avg;
cout<<"\n\nEnter 3 nos :\n\n";
cin>>x>>y>>z;
avg=(x+y+z)/3;
cout<<"\nResult = "<<avg;
cout<<"\n\nThank You";
}

Is This Answer Correct ?    1 Yes 2 No

write a program for function overloading?..

Answer / krithika

#include<iostream.h>
#include<conio.h>
class a
{
int area(int a)
{
cout<<"enter the side";
cin>>a;
return(a*a(;
}
float area(float l,float b)
{
cout<<"enter the length and breadth":
cin>>l>>b;
return(l*b);
}
};
int main()
{
clrscr();
a e;
int a;
float l,b;
cout<<"the area of a square"<<e.area(a);
cout<<"the area of a rectangle"<<e.area(l,b);
getch();
return 0;
}

Is This Answer Correct ?    29 Yes 34 No

Post New Answer

More OOPS Interview Questions

What is the different between Applet and Application?

2 Answers  


Name a typical usage of polymorphism

3 Answers  


What is oops with example?

0 Answers  


What is encapsulation in ict?

0 Answers  


where is memory for struct allocated? where is memory for class-object allocated? I replied for struct in stack and for class-object in heap. THen he asked if class has struct member variable what happens.class on heap and what about struct in that class? couldnt ans :( :-?

2 Answers   Infosys, Microsoft,






How can i write a code in c# to take a number from the user and then find all the prime numbers till the number entered by the user.

4 Answers   NIIT, TCS,


What are benefits of oop?

0 Answers  


Can we create object of class with private constructor?

5 Answers  


what type of questions

0 Answers   IBM,


What is the main difference between C++ and Java

11 Answers   TCS,


Can we define a class within the interface?

0 Answers  


Difference between new operator and operator new

2 Answers  


Categories