October 23rd, 2012, 03:51 PM
Sample Code Feedback.
Alright So, this is a simple code that I came up with for passing arrays to functions and performing a
mathematical operation on its elements.
Since I have no reference point, I would like to get an Idea of where I stand (Beginner @ the
moment, I know that much)
I would like to know if I am forming any bad habits or using some code incorrectly.
Now, I understand this is not a class but any feedback would be appreciated. I'm trying to
inch my way out of the newbie hole, and I want to make sure I'm doing it as correctly as possible
Plus, I've come to learn that not everything works the way they teach you in class, so.. anyway,
void harmony ( double ,int );
void fill ();
fill();//Call function to fill array
void fill ()
int *pa = new double ; //declare pointer to array of type double of 20 blocks.
double temp1 = 0.0;
double temp2 = 0.0;
int i = 0;
std::cout<<"Enter Pairs of Numbers Separated by a Space:"<<std::endl;
do // Prompt user for Input, use zero as a terminator.
if (temp1 != 0)
harmony (pa, i);
void harmony ( double arg , int limit )
double mean = 0.0;
for(int x= 0; x < limit; x++)
mean = 2 * (arg[x] * arg[x+1])/(arg[x] + arg[x+1]);
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.