Need some help with some code

This is a discussion on Need some help with some code within the C Programming forums, part of the General Programming Boards category; Here is my program... cant get the square meters and square feet to calculate. What am i doing wrong. I ...

Are you saying that when you run my code and enter 10 10 it works for you. On my computer using visual studio 2003 , lawn in square feet shows 0 and lawn in square meters shows 0. Did you do any adjustments

Thanks guys... it was driving me crazy. i have a bunch of excercises to do and so little time to do them.. at my slow rate of gettting the program to the point above i should be done in a year.... thanks again for the help...

Are you saying that when you run my code and enter 10 10 it works for you. On my computer using visual studio 2003 , lawn in square feet shows 0 and lawn in square meters shows 0. Did you do any adjustments

That's what I am saying, no adjustments, I'm using vs2005

Maybe there's a difference if you compile it as c++ or c. I used c++ but since you posted in the c forum I am guessing you compiled as c

In general the code should work fine ( I have no Idea if the conversion-factors are right but I assume they are ).
There is a problem with the conversion to square meters. You are using ints to hold the results. so

Code:

square_meters= (area_in_yards * 0.83612736);

will not calculate an accurate value.
The expression (area_in_yards * 0.83612736) will produce a double and this will be converted to an int by just discarding ( not rounding ) the digits after the decimal point. That's why for an input of 1x1 yards you will get a result of 0 square-meters.
Kurt