Write a program that produces a table converting distance in feet to distances in meters, for values of feet from 10 to 200, in steps of 10 feet. There are 39.37 inches in 1 meter, three feet in 1 yard, and 12 inches in 1 foot. You must use a loop.

I did:

# include <iostream>
# include <cmath>

using namespace std;

int main()

int i;
double inches = 39.37;
double feet = 3;
double foot = 12;
double meters = 39.37;
double yard = 3;

for (i=10; i=200; i++)
cout << "For values of feet from 10 to 200 are: " << feet << inches << foot << meters << yard << endl;
cin >> feet, inches, foot, meters, yard;
char feet;

while (i<=200)
cout << "The conversion is " << endl;

return 0;

Edited 6 Years Ago by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

See the objective of the program is to convert from feet to meters. If you use the information that is given in the problem statement ... you see that
10 feet = 12 inches
1 inch= 1/39.37 metres
10feet= 12*(1/39.37)metres

Now the program says that accept the input from the user. The user enters the value of feet. This value should be between 10 and 200. So when the user enters the input use a if condition to check if the value is indeed between 10 and 200.

If it is you use a loop to do the conversion. For example, if the user enters 30 feet, this contains 3 10 feets. Initialize a variable to 0. Add 12*(1/39.37) 3 times to the variable.

I hope this will help you to get further in your problem. Implement these points in your code. Read some tutorials on C/C++ programming to better your understanding of input/output, loops.


Edited 6 Years Ago by abhimanipal: n/a

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