Stay Tuned!

Subscribe to our newsletter to get our newest articles instantly!

C++ Programming

Function Overloading that Converts Fit into Inches

Function Overloading

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);
 }
Avatar

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.

You may also like

program to find leap year
C++ Programming

C++ Program to Find Leap Year by Using Function

  • March 3, 2016
Write a program to find if the inputted year is a leap year or not by using the concept of