Unit Conversion from feet to meters

Posted by user1742419 on Stack Overflow See other posts from Stack Overflow or by user1742419
Published on 2012-10-28T04:49:53Z Indexed on 2012/10/28 5:00 UTC
Read the original article Hit count: 117

Filed under:

I have to write a program that reads in a length in feet and inches and outputs the equivalent length in meters and centimeters. I have to create three functions: one for input, one or more for calculating, and one for output; And include a loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program. I can't seem to get the input from one function to be used in the conversion function and then outputted by the next function. How do I do that? Thank you.

#include <iostream>
#include <conio.h>

using namespace std;

double leng;

void  length(double leng);
double  conv(double leng);
void  output(double leng);


int main()
{
    length(leng);
    conv(leng);
    output(leng);

    _getche();
    return 0;
}

void length(double leng)
{
    cout<<"Enter a length in feet, then enter a length in inches if needed: ";
    cin>>leng;
    return;
}

double conv(double leng)
{
    return leng = leng * .3048;
}

void output(double leng)
{
    cout<<"Your input is converted to "<<leng;
    return;
            }

© Stack Overflow or respective owner

Related posts about c++