Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

why is the median, mean ,and mode functions cause errors?

+8 votes
asked Aug 11, 2025 by Ray Du (210 points)
reshown Aug 13, 2025 by Ray Du
/******************************************************************************

Welcome to GDB Online.

  GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,

  C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS

  Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/

#include <iostream>

#include <vector>

#include <algorithm>

#include <cmath>

#include <string>

using namespace std;

int main() {

int laoganma_michael;

cin>>laoganma_michael;

vector<int> grades;

for(int i = 0; i<laoganma_michael; i++) {

int thing;

cin>>thing;

grades.push_back(thing);

}

vector<string>names;

for(int j = 0; j<laoganma_michael; j++) {

string aoteman;

cin>>aoteman;

names.push_back(aoteman);

cout<<calculateMean(grades)<<endl

    cout<<calculateMode(grades)<<endl

    cout<<calculateMedian(grades)<<endl

}

    

return 0;

}

2 Answers

+2 votes
answered Aug 12, 2025 by Peter Minarik (101,340 points)

The compilation error happens because none of

  • calculateMean()
  • calculateMode()
  • calculateMedian()

function exists in your code (or in the imported libraries).

You'd have to implement them yourself.

0 votes
answered Aug 27, 2025 by hello (150 points)

You are calling those as functions [  also as USER DEFIND FUCNTION ]  , but you are not defining it's body, means what to perform if those functions are called. 

And if you are trying to use the INBUILT METHODS , but as such i know there is NO INBUILT METHODS to calculate them.

And also there is semicolon error at the end of each calling function 

    cout<<calculateMean(grades)<<endl ;
    cout<<calculateMode(grades)<<endl ;
    cout<<calculateMedian(grades)<<endl ;

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...