fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.  
  7. int arr_grades [5] ;
  8. int Total ;
  9. // fill array
  10. for (int i=0; i<5; i++)
  11. {
  12. printf(" Enter grade of course %i : ", i+1 );
  13. scanf("%i" , &arr_grades[i]);
  14. }
  15. // display array
  16. for (int i=0; i<5; i++)
  17. {
  18. printf(" the grade of course %i is %i \n", i+1,arr_grades[i]);
  19. // printf(" the adress of grade of course %i is %i \n", i+1,&arr_grades[i]);
  20. }
  21. // calculate total
  22. for (int i=0 ; i<5 ; i++)
  23. {
  24. Total += arr_grades[i] ;
  25. }
  26.  
  27. printf("your total grade is %i \n" , Total) ;
  28. printf("your average grade is %i \n" , Total/5);
  29.  
  30. //printf("the value of arr_grades is %i \n" , arr_grades);
  31. // printf("the value of arr_grades is %i \n" , &arr_grades);
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 5424KB
stdin
 
stdout
 Enter grade of course 1 :  Enter grade of course 2 :  Enter grade of course 3 :  Enter grade of course 4 :  Enter grade of course 5 :  the grade of course 1 is 0  
 the grade of course 2 is 0  
 the grade of course 3 is 1973818005  
 the grade of course 4 is 21867  
 the grade of course 5 is -1784505568  
your total grade is 189334304 
your average grade is 37866860