So I'm a new programmer and I'm SO close to finishing this code.
I want to return an array from a function, and every thread that I've looked up has said I need to return the data as a pointer TO an array.
How is that done?
Also, I'm working with Bloodshed, so the line system ("pause"); has always been part of my normal routine. I've been told that this isn't the best method, and I should instead say:
cout << "Press any key, then the enter key, to continue" << endl;
cin >> j;
This method obviously only works if you hit a character key. What can you do to pause the process without commanding the system to "pause"?
The code is as follows:
#include<iostream>
#include<math.h>
using namespace std;
//Function Prototype
void Eccentricity(float, float);
//Inline Function Definition
inline void Eccentricity(float a, float b [])
{
int m;
float E [7];
for (m=0 ; m<8 ; m++)
{
E [m] = sqrt(pow(a,2)-pow(b[m],2))/a;
return E;
}
}
int main()
{
//Declaring Variables
float a=0, E=0;
float b []= {.1, .2, .3, .4, .5, .6, .7, .8, .9};
int l;
cout << "This program calculates the eccentricity of a figure based on its semimajor axis for a set of likely semiminor axis" << endl;
cout << "What is the dimension of your semimajor axis?" << endl;
cin >> a;
//List of possible b values
for (l=0 ; l<8 ; l++)
{
b [l] = b[l]*a;
}
Eccentricity(a, b);
//Displaying Results
cout << "Your list of most likely eccentricities is as follows:\n" << endl;
//cout << "{" << E[1]<<", "<<E[2]<<", "<<E[3]<<", "<<E[4]<<", "<<E[5]<<", "<<E[6]<<", "<<E[7]<<", "<<E[8]<<"}"<< endl;
cout << E;
system ("pause");
return 0;
}