Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- int main(void) {
- FILE *fp;
- int nums[51];
- int i = 0;
- int counter = 0;
- int less = 0;
- int score = 1;
- fp = fopen("DATA", "r");
- while(!feof(fp)) {
- fscanf(fp, "%d", &nums[i]);
- counter++;
- i++;
- }
- while(score != -1)
- {
- printf("Enter a score to check on the exam: ");
- scanf("%d", &score);
- if(score == -1)
- {
- break;
- }
- for(i = 0; i < counter; i++)
- {
- if(nums[i] < score)
- {
- less++;
- //printf("%d\n", nums[i]);
- }
- }
- printf("%d scored lower than %d\n", less, score);
- less = 0;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement