problem with a simple program

Hi everybody, I'm new here. I have a question. I noticed an "error" in this simple program that I wrote to start my experience in c++ :
#include <iostream>
using namespace std;

int main()
{
int counter;
double Mpound, Epound;

counter = 0;

for(Epound == 1; Epound <= 100; Epound++) {

Mpound = (Epound / 100) * 17;
cout << Epound << " pound on the Earth is " << Mpound
<< " on the moon\n";

counter++;

if(counter == 25) {
cout << "\n";
counter = 0;

}

}

cout << "\n";
system ("PAUSE");

return 0;
}

When i compiled it and run it, at the top of the prompt there is one string:
"6.43705e-308 pound on the Earth is 1.0943e-308 on the moon" that i don't wrote!
I use Dev-C++ as IDE and compiler. Anyone can help me?
for(Epound = 1; Epound <= 100; Epound++) <- you need = here, not ==
It is probably because you are working with doubles. Try using floats.
And what is told above me /\
Last edited on
Yeah, because using an even less accurate type sure will help things along.

Use double unless you have good reasons to use float.
to m4ster r0shi: Thanks you're right! :)

to Spoking & Athar : I'm following the guide of Herbert Schildt and I'm at module 1, and I didn't "studied" float, only double, but thank you for your advise.
Topic archived. No new replies allowed.