C++ array find the average mark, highest mark, lowest mark, number of students passin

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KrossFaith
    New Member
    • Apr 2012
    • 1

    #1

    C++ array find the average mark, highest mark, lowest mark, number of students passin

    i need help in adding the c++ code for the average mark, highest mark, lowest mark, number of students passing, using array for this code.

    #include<iostre am>
    using namespace std;
    int main()
    {
    int range [4]= {0,0,0,0};
    int marks = 0;
    int counter = 0;
    cout << " Enter All The Marks" << endl;
    while (marks < 101)
    {

    cin >> marks;
    if (marks > 100)
    break;
    if (marks >= 70)
    range [3] ++;
    else if (marks >= 40)
    range [2] ++;
    else if (marks >= 30)
    range [1] ++;
    else
    range [0] ++;

    }
    while (counter < 4)

    {
    if (counter == 0)
    cout << "0 - 29 ";
    else if (counter == 1)
    cout << "30 - 39 ";
    else if (counter == 2)
    cout << "40 - 69 ";
    else
    cout << "70 - 100 ";
    for ( int i = 1; i <= range [counter] ; i ++)
    {
    cout << "*";
    }
    counter ++;
    cout << endl;
    }
    system("PAUSE") ;
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You are not actually entering the marks. What you do is enter a mark and test it and increment a counter but the mark is not recorded. Unless the mark is recorded it will be kinda hard to find averages, minimums an maximums.

    So:
    1) create an array of marks
    2) perform data entry and store the data in the array.

    Now you can iterate the array, add up the marks and divide by the number of array elements to get the average.

    Enough hints. Off you go...

    Comment

    Working...