Question
I'm having troubles running this program, why can't I get this c++ code to run? I'm getting 62 error messages. /******************************************************* * This program calculates
I'm having troubles running this program, why can't I get this c++ code to run? I'm getting 62 error messages.
/******************************************************* * This program calculates the average, median and * * mode of an array of elements entered as input * * and display them * ******************************************************/ /************************************************************* * Methods used : findAverage(),findMedian(), findMode() * * Input : Enter the number of students and * * the number of movies seen * * Output : Average, median and mode values * *************************************************************/ //Header section #include "stdafx.h" using namespace std; //Function prototype double findMedian(int[], int); int findMode(int[], int); double findAverage(int[], int); //Main function int main() { int n, i, j, tmp; int *movies; //Input values cout << "Enter how many students were surveyed:"; cin >> n; movies = new int[n]; cout << "Enter the number of movies each student saw: "; for (i = 0; i <= "" p = ""> { cin >> movies[i]; }
//Sorting for (i = 0; i <= "" p = ""> { for (j = i + 1; j <= "" p = ""> { if (movies[i]>movies[j]) { //swaping tmp = movies[i]; movies[i] = movies[j]; movies[j] = tmp; }//End of if } }
//showing functions double average = findAverage(movies, n); double median = findMedian(movies, n); double mode = findMode(movies, n); cout << "Average of Array " << average << endl; < p = "">< / average << endl; <> cout << "Median of Array " << median << endl; < p = "">< / median << endl; <> cout << "Mode of Array is :" << mode << endl; < p = "">< / mode << endl; <> system("pause"); return 0; }//End of main
//Function definition to find median double findMedian(int numbers[], int size) { //variable to store median double median; if (size % 2 == 0) median = (double)(numbers[size / 2] + numbers[size / 2 - 1]) / 2; else median = numbers[size / 2]; return median;//returning median }//End of function
//Function definition to find mode int findMode(int slices[], int size) { //variables to keep track count and mode int counter, mode = 0; //loop to found mode of an array for (int i = 0; i
//Function definition to find average double findAverage(int movies[], int size) { double average = 0; for (int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started