C++ Programming

Function Overloading that Converts Fit into Inches

Write a Program using the function overloading that converts fit into inches. Use function with no arguments, one argument and two arguments. Decide yourself the types of arguments. Use pass by reference in one of the function above.

Source Code

#include<iostream.h>
#include<conio.h>
float x,f;
void main()
{
 float length();
 float length(float &x);
 float length(float x,float y);
 cout<<"Enter length in feet"<<endl;
 cin>>x;
 f=length();
 cout<<"without using arguments"<<f<<endl;
 f=length(x);
  cout<<"using one argument"<<f<<endl;
 f=length(x,12);
  cout<<"using two arguments"<<f<<endl;
 getch();
 }
 float length()
 {
 return (x*12);
 }
 float length(float &a)
 {
  return (a*12);
  }
 float length(float a,float b)
 {
 return (a*b);
 }
Back to top button