fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int max( int arr[], int n ) {
  5. int max = arr[0];
  6. for (int i = 0; i < n; i++) {
  7. if (max < arr[i]) {
  8. max = arr[i];
  9. }
  10. }
  11. return max;
  12. }
  13. int main() {
  14. int n;
  15. cout<<"Enter the number of students: ";
  16. cin >> n;
  17. int *arr = new int[n];
  18. cout<<"Enter the grad of each student";
  19. for(int i=0;i<n;i++){
  20. cin>>arr[i];
  21. }
  22. cout<<"The highst grad is: "<<max(arr,n);
  23. return 0;
  24. }
Success #stdin #stdout 0s 5312KB
stdin
3
20
40
60
stdout
Enter the number of students: Enter the grad of each studentThe highst grad is: 60