- #1
shermaine80
- 30
- 0
Hi guys,
I'm stucked at these 2 questions from past years exam paper. Can someone advise me how to do it?
Q(1) Write a C program,marks that writes student marks to a newly created file. The program expects a file name to be passed on the command line and iis invoked like this: marks student.txt
(part 1) Declare three arrays, firstname, lastname and stdmark that stores the student first name, last name and examination mark (0-100) respectively. Assume that there are 5 students. But the program must be easily changed to cater to more students.
Initialise the arrays with sample name strings and the following marks: 47, 73,27,65,68
(part 2) A check for the command line arguments to ensure that the student file is specified. If not, the error message, "usage: marks infile", should be printed, and the program exits.
(part 3) The file must be created successfully,. If not, the program exits.
(part 4) A loop to write each students's name and mark in the output file.
(part 5) Any other code for successfult processing of the file.
I'm stucked at these 2 questions from past years exam paper. Can someone advise me how to do it?
Q(1) Write a C program,marks that writes student marks to a newly created file. The program expects a file name to be passed on the command line and iis invoked like this: marks student.txt
(part 1) Declare three arrays, firstname, lastname and stdmark that stores the student first name, last name and examination mark (0-100) respectively. Assume that there are 5 students. But the program must be easily changed to cater to more students.
Initialise the arrays with sample name strings and the following marks: 47, 73,27,65,68
(part 2) A check for the command line arguments to ensure that the student file is specified. If not, the error message, "usage: marks infile", should be printed, and the program exits.
(part 3) The file must be created successfully,. If not, the program exits.
(part 4) A loop to write each students's name and mark in the output file.
(part 5) Any other code for successfult processing of the file.
Last edited: