0

Usually when it's telling you that you have an "unitialized" local variable, it means that you accidentally misspelled it, and the computer isn't looking for your variable, eg, "msp" instead of "mps".

This may not be the case, but that is always what it has been for me.
Good Luck

Edit:
Oh, wait, that's obviously not your problem. Well...I dunno lol :D

Edited by A Tripolation: n/a

0

You're not having the user input them before they are passed into your functions(at least not in this snippet that you have posted, they are there in your other program), so they may never be defined before the function is called. Put in a cin statement to get the values. Temporarily you could set them to a value but that's probably bad practice.

Edited by jonsca: n/a

0

pfffft, finished. :P

I can't even get my height functions to work. Getting help from a friend tomorrow.

0

haha I think I'm almost done but I need just a little more help...

on line 20 i get

Warning1warning C4700: uninitialized local variable 'mps' used
Warning1warning C4700: uninitialized local variable 'angle' used

#include <iostream>
#include <cmath>
using namespace std;

double angtorad (double angle, double pi);
double distance_earth (double angle, int mps, double earth_gravity);
double distance_moon (double angle, int mps, double moon_gravity);
double distance_mars (double angle, int mps, double mars_gravity);
double height_earth (double angle, int mps, double earth_gravity, double earthx);
double height_mars (double angle, int mps, double earth_gravity, double marsx);
int main ()
{

	int mps;
	double angle;
	double pi =  3.1415927;
	double earth_gravity = 9.81;
	double moon_gravity = 1.62;
	double mars_gravity = 3.69;
	double earthx = (distance_earth(angle, mps, earth_gravity));
	double marsx =  (distance_mars (angle, mps, mars_gravity));
	double moonx =  (distance_moon (angle, mps, moon_gravity));

what do i need to change?

Whenever you declare numeric variables, you should set them equal to some value explicitly, (zero) is common, but it can be whatever you like as long as you know what it is. That way, you are not passing a garbage value into a function.

Also, where did your input prompts go? Are they after these assignment statements? If so, move them before (between lines 19 and 20). In general, you want to declare variables then process the information, but it's not always feasible. I'd suggest initializing earthx, marsx, and moonx to (zero) then use function calls to set the actual values after you have the user's input.

Edited by Fbody: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.