Question: 6. 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
6. 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 marks.txtwhich 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 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 marks.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 until the user enters a student 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 a student ID of 0. Finally, the main calls writemarks (passing it the output file pointer) to write out the revised marks. readmarks: takes a file pointer as an argument and reads the student IDs and marks into arrays id and marks. The function must also return the number of marks read. Assignment # 5 6 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, the function 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 writes the revised marks out to the output file in the same format as the input file (ID number followed by mark on each line).
For marking purposes, change the marks of student IDs 2315 and 2929 to 72 and 66, respectively.
#include
#include
#define MAXN 20 /* maximum number of marks */
int main(void) {
This is the file marks.txt:
1004 85
2315 65
1930 78
2000 69
2002 77
2100 87
2929 64
1345 60
please use simple C language, please do not use strings at all in this question. also please instead of using cout , cin and fp (to open file) use printf, scanf and FILE *fin or fout = fopen(" "); instead
Thank you so much
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
