C++ emergency need this word doc to be done and i can't do it my self cause it bit to hard for me plz help

Write a program to survey people, that will generate statistics about their age profile.
It will firstly ask for the sample size. Then it will ask you to enter the ages of every person in the sample. Once the data entry is complete the program should output:

the total age
the average age
the standard deviation
the median

plz help

#include <iostream>
#include <math.h>
using namespace std;


int main();
{
void showMedian(int array, int size);  
     //Declare variabels
    int i;
    int x;      
    int middle;
    double age[100];
    double total = 0;
    double average = 0;
    double variance[100];
    double sd = 0;
    double scores[i];
    double temp = 0;
    double median = 0;


    
    //main program loop
            
    cout << "how many: ";
    cin >> x;
    
      //get the input
    for(x=0;x<=100;x++)
        {
        for(i=0;i<=100;i++)
            {
            if(scores[i]>scores[i+1])
                {
                temp=scores[i];
                scores[i] = scores[i+1];
                scores[i+1] = temp;
                }
            }
        } 
    //the median input and output
            
	middle = size / 2;
	if ( middle % 2)
	{
	average = ((array[middle]) + (array[middle + 1])) / 2;
	cout << "The median is: " << average << endl;
	}
	else
    {
	cout << "The median is: " << (array[middle + .5]) << endl;
    }
        
    
    for(i=0;i<=99;i++)
        {
        cout << "Enter an age: ";
        cin >> age[i];
        total = total + age[i];
        }
        
    average = total / 100;
    
    for(i=0;i<=99;i++)
        {
        variance[i] = (scores[i] - average);
        total = total + (variance[i]*variance[i]);
        }
        
    
    cout << "Total: " << total << endl;
    cout << "median: " << median << endl;
    cout << "Average: " << average << endl;
    cout << "Standard Deviation: " << sd << endl;
    cout << "Again: " << endl;
    
  
    system ("pause");
    system("cls");
    return 0;
    break;
}

plz help

Edited 4 Years Ago by Narue: Added code tags

Functions cannot be defined or declared inside of other functions.

Use this for reference:

#include <iostream>
using namespace std;

//Below is a function prototype or "declaration"
void ShowMessage();

//Entry-point.
int main()
{
   ShowMessage();
   //Compiler inserts "return 0;" automatically.
}

//Function body or "definition"
void ShowMessage()
{
   cout << "Hello, CPP world." << endl;
}

Also note that the entry-point is a definition only, but is still a function.

Edited 4 Years Ago by pseudorandom21: n/a

This article has been dead for over six months. Start a new discussion instead.