![]() |
| ||
| Help with Measurement converter Hey I am trying to teach myself C++ and i am having trouble with a measurement converter I am pretty sure my problem is in the line Yards = Meters * 1.094; but i don't know how else to write it, this is my code: #include <iostream> Your help would be greatly appreciated |
| ||
| Re: Help with Measurement converter 2 things. Change : namespace std;to using namespace std;. Your code shouldn't compile without changing it. then change: int Meters;to: double Meters; Int can only be integer values So: 1, 4 , 300, 5632 etc etc. But you need some digits after the comma, so you need the double data-type |
| ||
| Re: Help with Measurement converter The mistake is that you are using integers (the set 0,1,2,3 and -1 etc) to represent floating point number. int a=2*1.2;gives sets a to 2. write double Meters;instead of the two int declarations. |
| ||
| Re: Help with Measurement converter Thanks for the help niek_e and StuXYZ it works perfectly now and i cant believe i forgot to put using before namespace. |
| ||
| Re: Help with Measurement converter Hey I Use Visual 2008 C++ Express and i don't know how to link this code to a GUI so that when i type the number of meters into a text box and press a button it will return the answer in a second text box. If you know of a tutorial on GUI's i could use it would be great. Thanks |
| ||
| Re: Help with Measurement converter Hey I have decided that a GUI is to Advanced for me to try at the moment and am going to keep reading my book. |
| All times are GMT -4. The time now is 12:45 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC