C++ intro lesson:variables

relevant exercise link

Hi I cant figure out why the output isn’t what I intend mathematically for mass_moon.
Note: I’m aware the conversion of mass earth–> mass moon is incorrect, I input a simple constant to test whether the math would check out, and it doesn’t.

If you look at your code, on line 7 you’re making the calculation, but you don’t actually take in a value until line 10.
So, mass_earth just has some default value which gives you the odd answer.

Hope that helps

1 Like