Advertisement
Guest User

Untitled

a guest
May 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. /*
  2.  
  3. Name: <type your name, as shown on your student ID>
  4.  
  5. Admin No:
  6.  
  7. Class:
  8.  
  9. */
  10.  
  11. #include <stdio.h>
  12.  
  13. extern float compMarks[ ] ; // declare as an external global variable
  14.  
  15. void main(void)
  16.  
  17. {
  18.  
  19. //declare variables total (float), k (integer) & grade (character)
  20.  
  21. float total;
  22.  
  23. int k;
  24.  
  25. char grade;
  26.  
  27. total=0.0 ; //initialise total with zero
  28.  
  29.  
  30.  
  31. //use for loop to display the data
  32.  
  33. printf("The values in the data file are: \n");
  34.  
  35.  
  36.  
  37. for ( k=0 ; k<7 ; k++ )
  38.  
  39. {
  40.  
  41. printf(" %.2f", compMarks[k]);
  42.  
  43.  
  44.  
  45. }//for
  46.  
  47.  
  48.  
  49. printf("\n\n");
  50.  
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement