Answer to Question #20197 in C++ for Jodi

Question #20197
I need help analyzing Netflix data, using global variables. I need to store the number of ratings and the sum of ratings in arrays. I need to write a function that that will give the average ratings for the movies.
1
Expert's answer
2012-12-07T04:12:30-0500

#include <conio.h>
#include <iostream>


using namespace std;

int numberofratings[100];
int number=0;
double averageratings (){
double sum=0;

for(int i=0;i<number;i++){
sum+=numberofratings[i];
}
return sum/number;
}
int main()
{

cout<<"Enter number of ratings: ";
cin>>number;

for(int i=0;i<number;i++){
cout<<"Enter value of rating "<<(i+1)<<":
";
cin>>numberofratings[i];
}

cout<<"Average ratings= "<<averageratings();
getch();
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS