Answer to Question #299151 in C++ for Not

Question #299151

write a program using delphi to calculate and store the average obtained by 5 students and print the student that made the highest mark


1
Expert's answer
2022-02-18T01:21:10-0500
#include <iostream>

using namespace std;

int main() {
  int students[5];
  for (int i = 0; i < 5; i++) {
    cin >> students[i];
  }
  int max = INT_MAX;
  int idx = 0;
  for (int i = 0; i < 5; i++) {
    if (max < students[i]) {
      max = students[i];
      idx = i;
    }
  }
  cout << "Student number " 
       << idx + 1 
       << " has highest mark\n";
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog