write a program for function overloading?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the concepts involved in Object Oriented programming.

638


Why do we use oop?

605


What is static modifier?

630


What is the use of oops?

621


write a code for this. serial_number contained in the header of the file will be read , if this serial number is less than a previous serial number within a successfully processed file, or is the same as another serial number within a successfully processed file, or if the field contains anything other than 7 digits, then the file must error with the reason ‘Invalid SERIAL_NUMBER’.

1780






program for insertion ,deletion,sorting in double link list

2281


How do you achieve runtime polymorphism?

571


What is oops in programming?

568


is there any choice in opting subjects like 4 out of 7

1731


Why do we need oop?

671


Can an interface inherit a class?

561


What is destructor in oop?

625


What are functions in oop?

584


What is encapsulation in ict?

608


Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)

3555