Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m having troubles running this program, why can\'t I get this c++ code to run

ID: 3861693 • Letter: I

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 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<size; i++)< p = "">< / size; i++)<>
       {
           counter = 1;
           //if two adjacent elements equals
           while (slices[i] == slices[i + 1])
           {
               counter++;
               i++;
           }
           if (counter>mode)
               mode = slices[i];//replacing mode
           if (counter>1)
               i--;
       }
   return mode;//returning mode
}//End of function

//Function definition to find average
double findAverage(int movies[], int size)
{
   double average = 0;
   for (int i = 0; i<size; i++)< p = "">< / size; i++)<>
       average += movies[i];
   average /= size;
   return average;
}

Explanation / Answer

/*******************************************************
* 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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote