### how to stop infinite loop

I have to submit this coding for school and when I try to submit it, it says, "program end never reached(commonly due to an infinite loop or infinite recursion)."

How do I get my coding to stop infinite looping? If you could fix my coding, I would be grateful. Thanks!

 ``1234567891011121314151617181920212223242526272829303132`` ``````#include #include using namespace std; int main() { double mass,weightEarth,weightMoon,weightMars; //constants for earth,moon and mars const double earth = 9.81; const double moon = 1.62; const double mars = 3.77; cout<>mass; cout<<"\nThe mass is "<=1000) cout<<"\nThe mass is heavy"; } return 0; }``````

[/code][/code]
Last edited on
It's not a problem with the code, what are you entering for mass ?

 C:\Temp>test126 Input the mass : 100 The mass is 100.000 kg Location Weight (N) Earth 981.000 Mars 377.000 Moon 162.000 C:\Temp>test126 Input the mass : 123456789 The mass is 123456789.000 kg Location Weight (N) Earth 1211111100.090 Mars 465432094.530 Moon 199999998.180 The mass is heavy
I'm entering 150 as the mass because that what my assignment says..
closed account (48T7M4Gy)
Setting code out clearly and with regular use of braces and whitespace helps. if ... else if ... else probably wasn't needed and is a tip it's a structure to avoid for maintaining clarity.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748`` ``````#include #include using namespace std; int main() { double mass,weightEarth,weightMoon,weightMars; //constants for earth,moon and mars const double earth = 9.81; const double moon = 1.62; const double mars = 3.77; cout<>mass; cout<<"\nThe mass is "<=1000) { cout<<"\nThe mass is heavy"; } else { cout << "Who knows what happens here?"; // <--- that's why! } } return 0; }``````