I am need help on array

#include<iostream> // required for cin , cout
#include<cmath> // required for sqrt()

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, sum1=0, mean, temp, max, min, range, std, variance;

// find the mean
for (int count=0; count<=(size-1); count++)
{

sum=sum+R[count];// add up all numbers in the array
}

mean= ;

// Sort the data

for( int i=0; i<=size-2; i++)
{
for( int j=i+1; j<=size-1; j++)
{

if (R[j]>R[i])
// swap R[i] and R[j]
{
temp=R[i];
R[i]=R[j];
R[j]=temp;

}

}
}


for( int k=0; k<=size-1; k++)
{
sum1=sum1+(R[k]-mean)*(R[k]-mean);// add up (xi-mean)^2
cout<<R[k]<<endl;// print the sorted array
}

max= ;

min ;

range= ;

variance=sum1/ ;

std=sqrt(variance);

cout<<"The mean is "<<mean<<endl;
cout<<"The maximum is "<<max<<endl;
cout<<"The minimum is "<<min<<endl;
cout<<"The range is "<<range<<endl;
cout<<"The Variance
cout<<"The standard deviation is

/*double x=3, y=5, sum=0, sub, mul, div;

cout<<"Welcome to EGR120! Today is April 7"<<endl<<endl;
cout<<"Please enter two integers, x and y. The value of y can not be zero."<<endl;
cin>>x>>y;


sum=x+y;
sub=x-y;
mul=x*y;
div=x/y;

cout<<x<<" + "<<y<<" = "<<sum<<endl;
cout<<x<<" - "<<y<<" = "<<sub<<endl;
cout<<x<<" * "<<y<<" = "<<mul<<endl;
cout<<x<<" / "<<y<<" = "<<div<<endl; */

system("pause");

}

This is the questions that have difficulty

The number lists shows the resistances, in ohms, measured for each resistor in the batch. Write a computer program to determine the following:

(a) Maximum
(b) Minimum
(c) Range
(d) Mean
(e ) Standard deviation
(f) Variance
(g) Median
Please put your code in between [code] and [/code] tags, it makes it more legible (it keeps your indentation and it also colours the text).

What is it specifically that you're having trouble with?
1
2
3
4
5
6
7
8
9
10
11
mean= sum / ( sizeof( R ) / sizeof( double )   ) ; 

	max=  R[(sizeof(R) / sizeof(double) ) -1 ] ;

min  = R[0];

range=  R[(sizeof(R) / sizeof(double) ) -1 ]  - R[0];

variance=sum1 ;

std=sqrt(variance);


Hope this helps .
It is my first time using this forum...I will post it with code tags(Chrisname).Thank you for your comment.

And bluecolor THANK YOU IT WAS NICE OF YOU. I WILL LET YOU AFTER I APPLY THOSE CODES.

Last edited on
Topic archived. No new replies allowed.