### Very new at this

I am very new at this but want to learn more, currently im working on the following code that calculates mean, maximum, minimum, and range
but im having a few errors and need help resolving them and understanding why it didnt work. All help is greatly appreciated.
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990`` `````` #include #include using namespace std; int main() { const int size=56; double R[size]={45.3, 67.8, 34.3, 51.2, 48.5, 61.3, 59.3, 65.1, 49.3, 42.4, 63.5, 69.8, 71.2, 39.8, 55.5, 53.2, 56.7, 48.8, 61.5, 51.2, 58.9, 63.1, 67.5, 62.4, 52.4, 50.2, 49.8, 56.8, 59.7, 60.4, 45.8, 43.8, 51.3, 54.8, 55.1, 52.3, 56.2, 59.7, 63.0, 46.7, 63.1, 58.2, 41.9, 59.2, 57.2, 67.3, 68.2, 38.9, 51.3, 63.8, 53.4, 58.9, 56.3, 58.9, 53.2, 56.8}; double sum=0, mean=0, max=0, min=100, range=0, sum1=0, variance=0, std=0; //cout<max) max=R[count]; // find the minimum if (R[count] min) min=R[count]; } mean= range= // find the variance for(int V=0; V<=size-1; V++) { sum1=sum1+( )*( ); } variance=sum1/( ); std=sqrt(variance); cout<<"The mean is "<>x>>y; sum=x+y; diff=x-y; mul=x*y; div=x/y; cout<<"The sum of "<
First off, welcome to the forums and you picked a great language to start with. However, one of the biggest things with C++ is understanding all of the syntax being able to debug your errors. But no worries, I'll help you out with this one. I'll start with the lines that are not commented.

Trying to compile it, I get these errors:
Code Blocks Compiler wrote:
C:\...\main.cpp||In function 'int main()':|
C:\...\main.cpp|35|error: expected ')' before 'min'|
C:\...\main.cpp|45|error: expected primary-expression before 'for'|
C:\...\main.cpp|45|error: expected ';' before 'for'|
C:\...\main.cpp|45|error: 'V' was not declared in this scope|
C:\...\main.cpp|45|error: expected ';' before ')' token|
C:\...\main.cpp|52|error: expected primary-expression before ')' token|
C:\...\main.cpp|85|error: 'system' was not declared in this scope|
||=== Build finished: 7 errors, 0 warnings ===|

The first error is on line 35. `if (R[count] min)` You're just simply missing your comparison operator, <, >, ==, or !=.

The second through the fifth error are all on lines 45. But there is two issues for this for statement. Lines 40 and 41 don't do anything and cause errors.
 ``12`` `````` mean= range=``````

Commenting those lines out gives me errors at line 48, you have a lot of spaces between the parenthesis, but no variables inserted in between.

If code is unfinished, it's best to comment them out until you can figure out what needs to be inserted to complete it.

We have this same issue on line 52, there seems to be a missing variable in the parenthesis in all of these cases.

And lastly, I got an error with the system("pause"); statement which you may or may not get. IF you get this error, simple include the line at the beginning of your code`#include <stdlib.h> ` with the rest of your preprocessor directives, i.e. #include statements.

Hope this helps get you pointed into the right direction.
No sure if the formulas are correct, but it should be something close.

Mike

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546`` `````` int main() { double sum=0, max, min, var=0, ave, std_dev; int i=0; double arr[]={45.3, 67.8, 34.3, 51.2, 48.5, 61.3, 59.3, 65.1, 49.3, 42.4, 63.5, 69.8, 71.2, 39.8, 55.5, 53.2, 56.7, 48.8, 61.5, 51.2, 58.9, 63.1, 67.5, 62.4, 52.4, 50.2, 49.8, 56.8, 59.7, 60.4, 45.8, 43.8, 51.3, 54.8, 55.1, 52.3, 56.2, 59.7, 63.0, 46.7, 63.1, 58.2, 41.9, 59.2, 57.2, 67.3, 68.2, 38.9, 51.3, 63.8, 53.4, 58.9, 56.3, 58.9, 53.2, 56.8}; for(i=0;iarr[i]) min=arr[i]; } cout<<"MIN is: "<
I think I've seen this before. It's a fill-in-the-blanks C++ homework assignment from somewhere.
Now that you mention it, I have seen this once or twice before. Not specifically this one, but I just helped a friend with their assignment the other day.

These are the easy ones too...

Thanks guys.

Still working on it.

I want to have the program calculate the mean and average of the set of numbers.

Im not sure how to code it which is why its basically blank.
Mean and average are the same exact thing. All you do is add all the numbers together and then divide...simple.

I meant variance.

I know its you have to take the distance each number is from the mean.
I've honestly never heard of the term variance, but rather standard deviation. But a simple google search gave me this.

http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance

I'll look into it.
Thanks
Ok,
so far i've gotten this.

Still have some errors but got rid of a few.

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192`` `````` #include #include using namespace std; int main() { const int size=56; double R[size]={45.3, 67.8, 34.3, 51.2, 48.5, 61.3, 59.3, 65.1, 49.3, 42.4, 63.5, 69.8, 71.2, 39.8, 55.5, 53.2, 56.7, 48.8, 61.5, 51.2, 58.9, 63.1, 67.5, 62.4, 52.4, 50.2, 49.8, 56.8, 59.7, 60.4, 45.8, 43.8, 51.3, 54.8, 55.1, 52.3, 56.2, 59.7, 63.0, 46.7, 63.1, 58.2, 41.9, 59.2, 57.2, 67.3, 68.2, 38.9, 51.3, 63.8, 53.4, 58.9, 56.3, 58.9, 53.2, 56.8}; double sum=0, mean=0, max=0, min=100, range=0, sum1=0, variance=0, std=0; //cout<max) max=R[count]; // find the minimum if (R[count] < min) min=R[count]; // find the mean of all the numbers mean=sum/R[count]; // find the range range=max-min; // find the variance variance=range-mean/R[count]; } for(int V=0; V<=size-1; V++) { sum1=sum1+( )*( ); } variance=sum1/( ); std=sqrt(variance); cout<<"The mean is "<>x>>y; sum=x+y; diff=x-y; mul=x*y; div=x/y; cout<<"The sum of "<

Still trying to figure out what to put in the ( ) blanks
Topic archived. No new replies allowed.