Can't find/don't know my error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <cmath>
using namespace std;
int main()


{
    int feet;
    float meters;

    for (feet=1; feet<=100; feet ++)

    cout<< feet << " feet is " << meters= feet/3.28;

    return 0;



}



I want to create a conversion table
Several. First, and most important, is that when you create a thread asking for help, make sure to explain what exactly is going wrong.

To make the compiler error go away, replace cout<< feet << " feet is " << meters= feet/3.28; with cout<< feet << " feet is " << (meters= feet/3.28);, you need to make it clear that the whole thing is 1 expression.

Next, you have a useless variable, you put information into meters, but you never read from it, that line would be identical to cout<< feet << " feet is " << feet/3.28;

Moving on, you are missing either an endl or \n to make it not display on 1 line.

Finally, your math is wrong.
Last edited on
Ok, thanks; how is the maths wrong?
I've got the table without changing the maths, and it appears to be correct.
A meter is longer then a foot.
Intrexa, I too am confused by how his math is wrong. 1 foot = 0.3048 meters, thus 1 meter = 3.28 feet
Then the calculation is correct.


100 feet is 30.48
Ah ha ha I am so terrible at life.

Wow, disregard
Topic archived. No new replies allowed.