Question
please use printf and scanf C Programming Assignment 10 Due Friday, April 20, 2018 For the program assigned below, submit the following: Hard copy of
please use printf and scanf
C Programming Assignment 10
Due Friday, April 20, 2018
For the program assigned below, submit the following:
Hard copy of the source code and output file
Copy of the source code (.c file), input file, and output file saved as electronic attachments to C Assignment 11 located in Canvas under Assignments.
Observe the usual guidelines regarding the initial comment section, indenting, and so on.
Place function prototypes before function main. Place function definitions following main.
Before each function use comments to explain what the function does.
Do not use any global variables.
The scores for 20 hypothetical students in a class on three tests are shown below.
Student ID Number | Test 1 | Test 2 | Test 3 |
Write a program that will compute statistics on the test scores above.
Create a project in Visual Studio and add a new .c file.From the Project pull down menu go to Add New ItemUtilityTextFile. Give the file a name and click Add. Copy and paste into the file the data table above, containing on each line the student ID number and the three test scores for that student, separated by spaces. Do not include column headings.
In function main declare but do not initialize a one-dimensional array of Ids with 20 elements and a two dimensional array of test scores with 20 rows and 3 columns. The number of rows and columns may be declared as defined constants. (Alternatively, you may put Ids and scores all in the same 2-dimensional array as long as you remember that Ids are in column 0 and test scores are in columns 1, 2, and 3.) Call the following functions from main (using function names of your own choosing.
Function readData reads the Ids and test scores from a data file.
Within the function you may declare a pointer to a file and then do the following: Open your text file for reading and assign the address returned from the fopen command to the file pointer. Check to see that the file opened successfully. Use fscanf in the appropriate loop structure to read in the Ids and scores. Close the file.
Required function parameters are the one-dimensional array of IDs and the two-dimensional array of scores. Although it is preferred coding to include the number of rows and columns of test scores as function parameters, it is permissible for this assignment just to use the symbolic constants for ROWS and COLS throughout. (If you cannot get this function to work you may initialize the array(s) at declaration in function main with a 2-point deduction in your score.)
Function testAverages receives the 2-D array of test scores and calculates the average of each test. Test averages should be floating point numbers and they should be placed in a 1-D array. The array of test scores and the array of test averages are the function parameters. Although it is preferred coding to include the number of rows and columns of test scores as function parameters, it is permissible for this assignment just to use the symbolic constants for ROWS and COLS throughout.
Function studentAverages receives the array of test scores and calculates the average of the three test scores for each student. Student averages should be floating point numbers and they should be placed in a 1-D array. The array of test scores and the array of student averages (and number of rows and columns if not using symbolic constants) are the function parameters.
Function printResults should print the results to a file. In the function declare a pointer to a file for writing. Open the file and check to see that it opened successfully. Write the following output to the file using fprintf.
A labeled table of student Ids, test scores, corresponding student test averages, and letter grades (if calculated for extra credit).
A listing the three test averages just below the columns of test scores.
Averages and standard deviation may be printed with one decimal digit.
Close the file.
Extra Credit:
For two points extra credit determine a letter grade for each student according to instructions below. Print letter grades in the printResults function beside the test averages for each student.
Function letterGrade receives the array of test scores and array of student averages and calculates an array of letter grades for the students according to the following scale:
If the average score is 90% or more, the grade is A.
If the average score is 70% or more and less than 90%, check the third score. If the third score is more than 90%, the grade is A; otherwise the grade is B.
If the average score is 50% or more and less than 70%, check the average of the second and third scores. If the average of the two is greater than 70%, the grade is C; otherwise the grade is D.
If the average score is less than 50% then the grade is F.
The array of test scores, array of student averages, and array of grades (and number of rows and columns if not using symbolic constants) are the function parameters.
The scores for 20 hypothetical students in a class on three tests are shown below.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started