Convert feet to meter in C++ programming

In this tutorial, we will learn how to convert feet into the meter in C++ programming with some easy examples. In some situations, we might have come up with this type of requirements.

When we are converting meters to centimeters, we know that 1m =100cm so if we have some x meters we can multiply it 100 to convert it to centimeters i.e. x meters = x*100 centimeters. For example, we have 11.2 meter to convert it into centimeters we multiply it with 100, then it is equal to 11.2*100 =1120 centimeters.

Conversion of feet to meter in c++

Let’s learn with some easy examples.

we know that 1 meter =3.28084 foot,then 1 foot = 0.3048 meters.

The main logic of the program is,

To convert feet into meter we multiply given feet with 0.3048 then the resultant is converted into meters.

using namespace std;
void main()
 double feet,mtr;
 cout<<"enter the length in feet\n";
 cout<<mtr <<"meters";

Here, in this code, we took variable data type as double because our input can be any floating point number which can be of any length so we took data type as double.

if our input is of small length then we can even take the data type as float.

cout and cin are basic input and output statements.

we see this code with some examples,

let us enter the length as 10 then the output will be 10*0.3048 = 3.048 meters.


enter the length in feet:
3.048 meters.

one more example,

let us enter the length as 125 then the output will be 125*0.3048 = 38.1 meters.


enter the length in feet:
38.1 meters.

Similarly, we can take other examples and check for the output.

Also, read:

So we are able to convert feet to meter in C++ programming language. I hope, you enjoyed this unit changing process that we have done with C++.

One response to “Convert feet to meter in C++ programming”

  1. tumwesigye isaac says:

    which compiler is more amplicable …..and instead of double can i use float

Leave a Reply

Your email address will not be published. Required fields are marked *