amlxv

entity

Nov 8th, 2019 (edited)
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int getMax = 0;
  8.     int getMin = 99999;
  9.     int i = 1;
  10.     int mark;
  11.     int num = 1;
  12.     int iMax;
  13.     int iMin;
  14.  
  15.     for(i=1; i<=5; i++){
  16.  
  17.         cout << "Enter the student " << num << " mark : " ;
  18.         cin >> mark;
  19.         num++;
  20.  
  21.         if(mark > getMax){
  22.  
  23.             getMax = mark;
  24.             iMax = i;
  25.  
  26.         }
  27.  
  28.         if(mark < getMin){
  29.  
  30.             getMin = mark;
  31.             iMin = i;
  32.         }
  33.  
  34.     }
  35.  
  36.     cout << "\nThe lowest of quiz mark is " << getMin << " which is from student " << iMin << endl;
  37.     cout << "The highest of quiz mark is " << getMax << " which is from student " << iMax << endl;
  38.  
  39. }
Add Comment
Please, Sign In to add comment