Write a program to read a set of scores from a text file named input.txt (assume
ID: 3659157 • Letter: W
Question
Write a program to read a set of scores from a text file named input.txt (assume it is in the same folder as your program), count the scores over 90, copy the scores over 90 to a new file named output.txt, and print the number of scores over 90 to the monitor. ex: if input contains scores: 85 95 78 90 82 output should be: 95 90 program should print out : There are 2 scores over 90 in the file.Explanation / Answer
#include int main() { FILE *fp1,*fp2; int value; int count=0; fp1=fopen("input.txt","r"); fp2=fopen("output.txt","w"); printf(" Output is:"); while(!feof(fp1)) { fscanf(fp1,"%d",&value;); if(value>=90) { printf("%d ",value); fscanf(fp2,"%d",value); count++; } } printf(" There are %d scores over 90 in the file.",count); fclose(fp1); fclose(fp2); return 0; }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.