Question: ******PLEASE USE WITH BELOW CODE BLOCKS TO SOLVE THE ASSIGNMENT********** #include #define MXN 100 int main(void) { int id[MXN], n = 0, i, theId, found;

******PLEASE USE WITH BELOW CODE BLOCKS TO SOLVE THE ASSIGNMENT**********
#include
#define MXN 100
int main(void) {
int id[MXN], n = 0, i, theId, found;
float mark[MXN], newmark;
FILE * fin = fopen("marks.txt", "r");
FILE * fout = fopen("marksout.txt", "w");
// read data from file into two arrays id and mark
n = readmarks(fin, id, mark);
// update marks
while(1) {
printf("Enter id (0 to quit) and the new mark: ");
scanf("%d", &theId);
if (theId == 0) break;
scanf("%f", &newmark);
found = changemarks(n, id, mark, theId, newmark);
if (!found) { // found = 0
printf("Student id %d was not found ", theId);
}
}
writemarks(fout, id, mark, n);
fclose(fin);
return 0;
}
4. Write a program marks.c which consists of a main function and three other functions called readmarks, changemarks, and writemarks The program begins by calling the function readmarks to read the input file marksin.txt which consists of a series of lines containing a student ID number (an integer) and a numeric mark (a float) Once the ID numbers and marks have been read into arrays (by readmarks), the main program asks if the user wants to adjust a mark. If so, the user enters an ID number and the new mark. The main then calls the function changemarks to change the mark associated with the provided student ID. The main then asks the user if they want to adjust another mark, and so on, until the user enters a student ID number of 0. Finally, the main calls the function writemarks to write the marks out to a file called marksout.txt. You may assume that the input file will consist of no more than 20 marks. In detail, your functions should perform the following main: opens the input file marksin.txt and the output file marksout.txt and then calls readmarks, passing it the input file pointer, to read the IDs and marks into two arrays. Once the arrays have been read, the main then prompts the user to enter a student ID and the revised mark, calls changemark to revise the mark, and repeats these steps until the user enters a student ID number of 0. If changemark cannot find the student ID in the list of possible IDs, the main should print out an error message, then prompt for the next student ID and revised mark. The user quits revising marks by entering the student ID number of 0. Finally, the main calls writemarks (passing it the output file pointer) to write the revised readmarks: takes a file pointer and the arrays as arguments and reads the student IDs and marks into arrays id and marks. The function must also return the number of marks read. changemarks: this function should take 5 values as arguments: 1) the number of marks read, 2) the ID array 3) the marks arrays, 4) the ID number of the student whose mark is to be revised, and 5) the revised mark. The function should then revise the mark of the student with the ID specified in the 4th argument. If the function cannot find the specified student ID in the ID array, it should return 0. Otherwise the function should change the mark and return 1. (NOTE: if this function returns 0, the main should report "That student is not in the marks list".) writemarks: this function should take as arguments a file pointer, the number of marks, the ID array, and the marks array, and write the revised marks out to the output file in the same format as the input file (an ID number followed by the mark on each line) For marking purposes, change the marks of the students with the ID numbers of 2315 and 2929 to 72 and 66, respectively
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
