#include<iostream>
using namespace std;


float input()
{
float inches;
float feet;
cin>>inches;
cin>>feet;




};

float calculate(float inches, float feet)
{
    float cm;
    float meters;

    cm=2.54*inches;
    meters=feet*.3048;

};



float output(float meters,float cm)
{
    cout<<"The feet to meters="<<meters<<endl;
    cout<<"The inches to cm="<<cm<<endl;
};

void main()
{    

   float input();
   float calulate();
    float output();





};

I need help this wont work

Write a program that will read in a length in feet and inches
and will output the equivalent length in meters and centimeters. Use at least
three functions : one for input, one or more for
calculating and one for output. There are 0.3048 meters in a foot, 100
centimeters in a meter and 12 inches in a foot.

Why is it so hard to explain what is wrong for you noobs? We are programmers, not psychics. Tell us what you need help with!

Hi orar,

Looks like you're uncertain about functions at the moment. Here:

void main()
{
    float input();
    float calulate();
    float output();
};

Several problems.

The first is that you should remove the word float from the function call, e.g.

calculate();

The second is that the function is supposed to return a float value, so you need a variable to store the return value:

float value;
value = calculate();

If appropriate, you can combine these and initialise the variable with the return value:

float value = calculate();

The next problem is that the calculate function expects parameters and you're not passing any, e.g.

float inches = 3.1;
float feet = 4.2;
value = calculate(inches,feet);

Next, your calculate function isn't returning the value it's supposed to:

float calculate(float inches, float feet)
{
    float cm;
    float meters;
    cm=2.54*inches;
    meters=feet*.3048;
};

I assume you want to return the calculated value of metres:

float calculate(float inches, float feet)
{
    float cm;
    float meters;
    cm=2.54*inches;
    meters=feet*.3048;

    return meters;
};

Your other functions and function calls have similar problems. These are all pretty fundamental to using functions. Time to dig out your reference book or use Google and read up on functions before going any further.

Good luck with your program.

Edited 4 Years Ago by Bob

This article has been dead for over six months. Start a new discussion instead.