I'm having problems with my DisplayEntry function. What this program is supposed to do it display numbers that have been validated earlier in the program. The problem is it is displaying random numbers stored in the computer. I'm gonna include the struct declarations, the function call, and the actual function.

struct SourceType
{
	float latitude;
	float longtiude;
};

struct TravelType
{
	float time;
	float distance;
	float altitude;
};

struct TargetType
{
	float latitude;
	float longitude;
};

struct ProjectileData
{
	float speed;
	float azimuthal;
	float equatorial;
	SourceType source;
	TravelType travel;
	TargetType target;
};

DisplayEntry(data);

void DisplayEntry(ProjectileData data)
{
	cout << "\nThe Projectile is Launched With a Speed of: " << data.speed << endl;
	cout << "with an Azimuthal Angle of: " << (data.azimuthal) << endl;
	cout << "and an Equatorial Angle of: " << (data.equatorial) << endl;
	cout << "travels a Time of: " << ((2.0 * (data.speed) * (sin(data.azimuthal))) / (9.81)) << endl;
	cout << "over a Distance of: " << ((data.speed) * (cos(data.azimuthal)) * (data.travel.time)) << endl;
	cout << "reaches and Altitude of: " << ((9.81 * (data.travel.time) * (data.travel.time)) / (2.0)) << endl;
	cout << "departs from Coordinates: " << ((data.source.latitude) + (data.travel.distance) * (sin(data.equatorial))) << endl;
	cout << "and Arrives at Coordinates: " << ((data.source.longtiude) + (data.travel.distance) * (cos(data.equatorial))) << endl;
}

>>The problem is it is displaying random numbers stored in the computer
The problem is in the code you did NOT post -- show us the code that contains this line: DisplayEntry(data); Most likely it is passing an instance of a structure that contains uninitialized data.

When you declare the object, do it like this so that all elements are initialized to 0 ProjectileData data = {0};

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.