Thread: Mean, Median, and Mode .....code

  1. #1
    hacker in training AdamLAN's Avatar
    Join Date
    Sep 2004
    Posts
    56

    Cool Mean, Median, and Mode .....code

    I've written a simple code that finds the mean, median, and mode of a set of data. I have a compiler (MSVC++.net), but I can't install it. So I've written codes in notepad and will compile them later. If anyone finds any problems with this code, please tell me. And if you can help me, here's the problem with MSVC++.net:
    I'll insert CD1 and hit "install prerequisites", and it says the system must reboot, so it does so, and then I have to start over again (it doesn't restart Setup from where it left off.) What should I do?

    This is the code:

    #include <iostream>
    using namespace std;

    int main()
    {
    int exit=0;
    while (exit !=1)
    {
    int set[200];
    int a;
    int b[200];
    cout<<"How many numbers are in the set?"<<endl;
    cin>>a;
    cout<<"enter your set, one number at a time:"<<endl;
    for (int c=0, c<a, c++)
    {
    cin>>b[c];
    }
    for (c=0, c<a, c++) //bubble sort
    {
    if (b[c]>b[c+1])
    {
    int temp;
    temp = b[c];
    b[c]=b[c+1];
    b[c+1]=temp;
    temp=0;
    }
    }
    for (c=0, c<a, c++)
    {
    for (int e=0, e<c, e++)
    {
    int sum = b[c]+b[e];
    }
    }
    int average = sum/a; //finds average of data
    int z = a-1;
    double median = b[z/2];
    if (a%2==0)
    {
    temp =a/2;
    z=temp+1;
    int y =tmep-1;
    int x = z + y;
    median = x/2;
    x=0;
    y=0;
    z=0;
    temp=0;
    } //median

    int max = b[a];

    for (c=0, c<max, c++)
    {
    for (e=0, e<a, e++)
    {
    if (c==b[e])
    {
    int frequency++;
    }
    int num = b[e];
    int frequency2[a][1];
    frequency2[e][0]=frequency;
    frequency2[e][1]=b[e];
    }
    }
    for (c=0,c<a, c++)
    {
    if (frequency[e][0]>frequency[e+1][0])
    {
    temp=frequency[e][0];
    frequency[e][0]=frequency[e+1][0];
    frequency[e+1][0]=temp;
    temp=0;
    temp=frequency[e][1];
    frequency[e][1]=frequency[e+1][1];
    frequency[e+1][1]=temp;
    }
    }
    int mode = frequency[a][1];
    cout>>"The Mean is:"<<average<</n"The median is:"<<median<</n<<The Mode is:"<<mode;
    cout>>/n"Click one to exit, or any number to start over."<<endl;
    cin>>exit;
    }
    return 0;
    }

  2. #2
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>I'll insert CD1 and hit "install prerequisites",
    What happens if you don't install them?

    And do you have admin rights on that computer?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    Also, the [code] tags are your friend

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Statistical Mode Function
    By h4rrison.james in forum C Programming
    Replies: 5
    Last Post: 01-16-2009, 09:48 PM
  2. finding mode of an array
    By n00by in forum C Programming
    Replies: 1
    Last Post: 05-18-2004, 07:40 PM
  3. Finding Mode Median and Mean
    By Ginny Morgan in forum C Programming
    Replies: 3
    Last Post: 05-08-2003, 03:09 PM
  4. median mode
    By bobbydigital in forum C++ Programming
    Replies: 2
    Last Post: 04-12-2003, 08:53 PM
  5. Computing Mean, Median and Mode Using Arrays
    By Rodneo in forum C++ Programming
    Replies: 0
    Last Post: 05-29-2002, 11:40 PM