fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void print_table(int row, int col, double marks[row][col])
  5. {
  6. int i,j;
  7. for(i=0; i<row; i++)
  8. {
  9. for(j=0; j<col; j++)
  10. {
  11. printf("%02.1lf ",marks[i][j]);
  12. }
  13. printf("\n");
  14. }
  15. }
  16.  
  17.  
  18.  
  19. int main()
  20. {
  21. int number_of_students;
  22. printf("Enter number of students: ");
  23. scanf("%d",&number_of_students);
  24.  
  25. char student_name[number_of_students][50];
  26. int i,j;
  27.  
  28. for(i=0; i<number_of_students; i++)
  29. {
  30. printf("Student %d name: ",i);
  31. fflush(stdin);
  32. gets(student_name[i]);
  33. }
  34.  
  35. for(i=0; i<number_of_students; i++)
  36. {
  37. printf("Student %d name: ",i);
  38. puts(student_name[i]);
  39. }
  40.  
  41. int number_of_courses;
  42. printf("Enter number of courses: ");
  43. scanf("%d",&number_of_courses);
  44.  
  45. double marks[number_of_students][number_of_courses];
  46.  
  47. for(i=0; i<number_of_students; i++)
  48. {
  49. printf("Marks of %s: \n",student_name[i]);
  50. for(j=0; j<number_of_courses; j++)
  51. {
  52. printf("\t->Mark of course %d: ", j);
  53. scanf("%lf",&marks[i][j]);
  54. }
  55. }
  56.  
  57. /// Average mark of each student
  58. double total_mark[number_of_students];
  59.  
  60. for(i=0; i<number_of_students; i++)
  61. {
  62. total_mark[i] = 0;
  63. for(j=0; j<number_of_courses; j++)
  64. {
  65. total_mark[i] += marks[i][j];
  66. }
  67. printf("Average mark of %s is %0.2lf\n",student_name[i],total_mark[i]/number_of_courses);
  68. }
  69.  
  70. system("cls");
  71. print_table(number_of_students,number_of_courses,marks);
  72.  
  73.  
  74. /// highest mark of each student
  75. double highest_student_mark[number_of_students];
  76. for(i=0; i<number_of_students; i++)
  77. {
  78. highest_student_mark[i] = marks[i][0];
  79. for(j=0; j<number_of_courses; j++)
  80. {
  81. if(highest_student_mark[i] < marks[i][j])
  82. {
  83. highest_student_mark[i] = marks[i][j];
  84. }
  85. }
  86. printf("Highest mark of %s is %0.2lf\n",student_name[i],highest_student_mark[i]);
  87. }
  88.  
  89. /// HIGHEST NUMBER OF EACH COURSE
  90. double highest_course_mark[number_of_students];
  91. for(i=0; i<number_of_courses; i++)
  92. {
  93. highest_course_mark[i] = -1;
  94. for(j=0; j<number_of_students; j++)
  95. {
  96. if(highest_course_mark[i] < marks[j][i])
  97. {
  98. highest_course_mark[i] = marks[j][i];
  99. }
  100. }
  101. printf("\nHighest mark of course %d is %0.2lf\n",i,highest_course_mark[i]);
  102. }
  103. /// subject grade of each student
  104.  
  105. return 0;
  106. }
  107.  
Success #stdin #stdout #stderr 0.01s 5308KB
stdin
4
Sanzida
Tisa
Ety
Sifat
5
90
70
35
45
80
60
80
95
35
45
60
50
75
25
50
60
30
65
75
80
stdout
Enter number of students: Student 0 name: Student 1 name: Student 2 name: Student 3 name: Student 0 name: 
Student 1 name: Sanzida
Student 2 name: Tisa
Student 3 name: Ety
Enter number of courses: Marks of : 
Marks of Sanzida: 
Marks of Tisa: 
Marks of Ety: 
Average mark of  is -nan
Average mark of Sanzida is -nan
Average mark of Tisa is -nan
Average mark of Ety is -nan




Highest mark of  is 0.00
Highest mark of Sanzida is 0.00
Highest mark of Tisa is 0.00
Highest mark of Ety is 0.00
stderr
sh: 1: cls: not found