hai...im having a problem over here...this is my question.The program will continuously ask the user to enter student’s marks. When a student mark of -1 is entered, the program will display the students with the highest, lowest mark and the average of the class.. i have done the code, but than i dont know how to make the code to show the output for lowest and highest marks.
#include <iostream>
using namespace std;
int main()
{
int n, sum = 0, nums = 0 ;
do
{
cout << "Enter student marks (-1 = quit): ";
cin >> n;
if( n > 0 )
{
sum += n;
++nums;
}
} while( n > 0 );
if( nums > 0 )
cout << "The class average is: " << sum / nums << endl;
You will need to add logic that compares each value of n to the lowest value you've seen so far, and likewise for the highest value you've seen so far.