fork download
  1. #include <stdio.h>
  2. # define EXAMS 4
  3. # define STUDENTS 3
  4.  
  5. int maximum(const int grades[][EXAMS]);
  6. int minimum(const int grades[][EXAMS]);
  7.  
  8. int main(void) {
  9.  
  10. int studentGrades[STUDENTS][EXAMS] = {77,68,86,73, 96,87,89,78, 70,90,86,81};
  11.  
  12. printf("maximum:%d\n",maximum(studentGrades));
  13. printf("minimum:%d\n",minimum(studentGrades));
  14.  
  15. return 0;
  16. }
  17.  
  18. int maximum(const int grades[][EXAMS]){
  19.  
  20. int highscore = 0;
  21. int i,j;
  22.  
  23. for(i = 0;i < 2;i ++){
  24. for(j = 0;j < 3;j ++){
  25. if(grades[i][j] > highscore){
  26. highscore = grades[i][j];
  27. }
  28. }
  29. }
  30. return highscore;
  31. }
  32.  
  33. int minimum(const int grades[][EXAMS]){
  34.  
  35. int lowscore = 100;
  36. int i,j;
  37.  
  38. for(i = 0;i < 2;i ++){
  39. for(j = 0;j < 3;j ++){
  40. if(grades[i][j] < lowscore){
  41. lowscore = grades[i][j];
  42. }
  43. }
  44. }
  45. return lowscore;
  46. }
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
maximum:96
minimum:68