How do i find the highest and lowest mark?
I think i've made the statement but not sure where i should place it.. Thanks in advance
Here is the statement:
Code:
{
if (mark == cat_3 || mark == cat_4) {
cout >> “pass”<< student_pass << endl; }
else if (mark == cat_1 || mark == cat_2){
cout >> “fail” << student_fail <<endl; }
}
here is my code :
Code:
#include <iostream>
using namespace std;
int main ()
{
// name the variables of catergories
int cat_1 = 0; // category 1
int cat_2 = 0; // category 2
int cat_3 = 0; // category 3
int cat_4 = 0; // category 4
int i = 0;
int total_marks = 0; // total marks
int counter = 0; // adding the amount of marks entered by user
int average_mark = 0; // the average mark from all the marks put together
int pass = 0;
int fail = 0;
//number of students passing
//highest mark
//lowest mark
int mark = 0; // Marks entered by user
cout << "Please enter the marks the students has achived " << endl; // ask the user to enter the mark
cin >> mark; // marks the student achived from the user
for (i = 0; i<=9; i++) // loop
{
total_marks = total_marks + mark;
counter++; //total marks
if (mark >=0 && mark <=29){
cat_1 ++;
}
else if (mark >=30 && mark <=39){
cat_2 ++;
}
else if (mark >=40 && mark <=69){
cat_3 ++;
}
else if (mark >=70 && mark <=100){
cat_4 ++;
}
cin >> mark;
}
cout << "Number of students with marks 0-29|";
for (i = 0; i<cat_1; i++) {
cout << "*";
}
cout << endl;
cout << "Number of students with marks 30-39|";
for (i = 0; i<cat_2; i++) {
cout << "*";
}
cout << endl;
cout << "Number of students with marks 40-69|";
for (i = 0; i<cat_3; i++) {
cout << "*";
}
cout << endl;
cout << "Number of students with marks 70-100|";
for (i = 0; i<cat_4; i++)
{
cout << "*";
}
cout << endl;
cout << "The total amount of student marks is|" << counter << endl; // the number of student whose marks had been entered
for (i = 0; i<counter; i++) {
average_mark = total_marks / counter;//average mark between all the makes entered
}
cout << "The average mark is|" << average_mark <<endl;
system ("Pause");
return 0;
}