Give a description of what the program does


Give a description of what the program does and Class/Program Invariant for the following C++ code: 
#include
using namespace std;
void getinfo(int*, int);
void sort(int [], int);
double average(int*, int);
double median(int*, int);
int get_mode(int*, int);
int main()
{ int*array; 
int num; 
int mode,i,range;
float avg;
cout<<"Enter the number of students to be evaluated: ";
cin>>num;
while(num<=0)
{cout<<"Invalid Entryn";
cout<<"Enter the number of students to be evaluated: ";
cin>>num;
}
array=new int[num];
getinfo(array, num);
cout<<"nThe array is:n";
for(i=0;icout<<"Student "<sort(array, num);
cout<<"the median is "<cout<<"the average is "<mode=get_mode(array, num);
if(mode<0)
cout<<"There is no mode.n";
else
cout<<"The mode is " << mode << endl;
delete [] array;
system("pause");
return 0;
}
void getinfo(int a[], int n)
{int i;
for(i=0;i{cout<<"Student "<<(i+1)<< " watched how many movies? ";
cin >> a[i];
while(a[i]<0) 
{cout<<"Invalid entry, must be >= 0n";
cout<<"Student "<<(i+1)<< " watched how many movies? ";
cin>>a[i];
}
}
}
double average(int a[], int num)
{ int tot=0,i;
double avg;
for(i=0;itot+=a[i];
avg=(double)tot/num;
return avg;
}

void sort(int a[], int n)
{ int i,j,t;
for(i=0;ifor(j=i;jif(a[i]>a[j])
{t=a[i];
a[i]=a[j];
a[j]=t;
}
}
double median(int* a, int n)
{ int m1,m2;
if (n%2==0)
{m1=n/2;
m2=(n/2)-1;
return((*(a+m1)+*(a+m2))/2.);
}
else

return *(a+(n/2));
}
int get_mode(int* a, int n)
{
int* count,most,index,i,j;
count= new int[n];
for (i= 0;i< n;i++)
count[i] = 0;
for(i=0;i{for(j=0;j{if(*(a+j)==*(a +i))
(*(count+i))++;
}
}
most=*count;
index=0;
for (i=1;i{if (*(count+i) >most)
{most=*(count+i);
index=i;
}
}
if (most == 1)
return -1;
else
return *(a+index);

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Give a description of what the program does
Reference No:- TGS0112395

Expected delivery within 24 Hours