Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int main(void) {
  5. FILE *fp;
  6. int nums[51];
  7. int i = 0;
  8. int counter = 0;
  9. int less = 0;
  10. int score = 1;
  11.  
  12. fp = fopen("DATA", "r");
  13.  
  14. while(!feof(fp)) {
  15. fscanf(fp, "%d", &nums[i]);
  16. counter++;
  17. i++;
  18. }
  19.  
  20.  
  21.  
  22. while(score != -1)
  23. {
  24. printf("Enter a score to check on the exam: ");
  25. scanf("%d", &score);
  26.  
  27. if(score == -1)
  28. {
  29. break;
  30. }
  31.  
  32. for(i = 0; i < counter; i++)
  33. {
  34. if(nums[i] < score)
  35. {
  36. less++;
  37. //printf("%d\n", nums[i]);
  38. }
  39.  
  40.  
  41. }
  42.  
  43. printf("%d scored lower than %d\n", less, score);
  44. less = 0;
  45. }
  46.  
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement