Function overloading – Inch to centimeter conversion – CSKC
Sign In

Search

Solved Problem #CPP#4483    siteicon   siteicon  

Problem Statement - Function overloading – Inch to centimeter conversion

Write two overloaded functions as follows:

Function 1:
Convert integer input parameter which is a number given as inches of some measurement to a double number which is of centimeter measurement

Function 2:
Convert double input parameter which is a number given as inches of some measurement to a double number which is of centimeter measurement

use conversion formula as 1 inch = 2.54 cm.

Also show the implementation of both the functions in the main routine.

Solution

TC++ #4483

 

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

double inch2cm(int x) { return x*2.54; }
Conversion function when input is integer data type.

double inch2cm(double x) {return x*2.54;}
Conversion function when input is double data type.

int n=3;
double d=5.1237;
cout<<inch2cm(n)<<endl;
Calling related function when input is integer

cout<<inch2cm(d)<<endl;
Calling related function when input is double


Suggested Filename(s): func-ol2.cpp



Share

Created: 26-Aug-2018 02:08 | Updated: 26-Aug-2018 02:09|