Question

To answer this question you must submit a fully functional "C" program, this is your "main.c"...

To answer this question you must submit a fully functional "C" program, this is your "main.c" file.

This is the content of the Grades.txt file (download here)
Adam 4.00 7.00 9.00 10.00
Catherine 10.00 8.00 1.00 9.00
John 10.00 9.00 7.50 6.50
Pedro 10.00 9.00 7.50 9.00
Wanda 9.00 6.50 4.50 10.00

In the file Grades.txt you will find that each line contains the name of a student and his 4 grades for the current term.

Create a C program to open the file Grades.txt, and from each line of the file read the name of the student and his 4 grades using fscanf, then calculate and print in the screen a table with the final/average grade for each student.

Please have in mind the following rules:

  • You can use any C program code from the textbook or from the Self Review Exercises to start working on this question.
  • Your program MUST use the fscanf function to read the data from the Grades.txt file

The following is an example of how your program should run:

Adam: 7.50
Catherine: 7.00
John: 8.25
Pedro: 8.88
Wanda: 7.50

Process returned 0 (0x0)
Press any key to continue.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
   FILE *fp;
   char name[50];
   float avg,mark1,mark2,mark3,mark4;

   fp = fopen("Grades.txt", "r");

if(fp == NULL)
{
printf("Error opening file\n");
exit(1);
}
while (fscanf(fp,"%s %f %f %f %f",name,&mark1,&mark2,&mark3,&mark4) !=EOF)
   {
       avg=(mark1+mark2+mark3+mark4)/4;
       printf("%s: %.2f\n", name,avg);
   }
   return 1;
}

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
To answer this question you must submit a fully functional "C" program, this is your "main.c"...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Language A continuation of your grading software will be made you do not need your...

    C++ Language A continuation of your grading software will be made you do not need your other code for this assignment). In this one you will intake a students first name and last name from a file called "students.txt". Next, there is a file called grades.txt that contains the grades in a course. There will be three grades for each student in "grades.txt" (see example file bellow). In "student.txt" there are two students first and last names. In "grades.txt" the...

  • You must assume that the data file and your four function subprograms are located inside the working directory (forder). Please write the main program and each of the four function subprograms. 1. Th...

    You must assume that the data file and your four function subprograms are located inside the working directory (forder). Please write the main program and each of the four function subprograms. 1. The data in the following table are to be read from the file "grades.txt"and processed The grades are in percentages. The format of the data is shown below First Name ID Number Last Name Grades 001AA Tam 78.50 oe 86.45 001AB Gabriel Stuart Thus, there are 4 columns...

  • (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that...

    (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that you have been provided on Canvas. That file has a name and 3 grades on each line. You are to ask the user for the name of the file and how many grades there are per line. In this case, it is 3 but your program should work if the files was changed to have more or fewer grades per line. The name and...

  • Java program Program: Grade Stats In this program you will create a utility to calculate and...

    Java program Program: Grade Stats In this program you will create a utility to calculate and display various statistics about the grades of a class. In particular, you will read a CSV file (comma separated value) that stores the grades for a class, and then print out various statistics, either for the whole class, individual assignments, or individual students Things you will learn Robustly parsing simple text files Defining your own objects and using them in a program Handling multiple...

  • IN C You will be creating a program to help a teacher calculate final grades for...

    IN C You will be creating a program to help a teacher calculate final grades for a class. The program will calculate a final letter grade base on a standard 90/80/70/60 scale. You will be taking input from a file that contains all of the names and grades of each student. You will find the average for each student and output each student's final letter grade. Your program should accept the filename from the command-line Add error checking to make...

  • Write a C++ program to store and update students' academic records in a binary search tree....

    Write a C++ program to store and update students' academic records in a binary search tree. Each record (node) in the binary search tree should contain the following information fields:               1) Student name - the key field (string);               2) Credits attempted (integer);               3) Credits earned (integer);               4) Grade point average - GPA (real).                             All student information is to be read from a text file. Each record in the file represents the grade information on...

  • Please don't use a void fuction and this is a c++ question. Thanks Write a program...

    Please don't use a void fuction and this is a c++ question. Thanks Write a program that reads two input files whose lines are ordered by a key data field. Your program should merge these two files, writing an output file that contains all lines from both files ordered by the same key field. As an example, if two input files contain student names and grades for a particular class ordered by name, merge the information as shown below Using...

  • Within this C program change the input to a file instead of individual input from the...

    Within this C program change the input to a file instead of individual input from the user. You must take the input file name on the command line. Be sure to have simple error checking to be sure the file exists and was successfully opened. The input file will have the following format: First line: Number of students Second Line: Number of grades Third Line: Student Names, space delimited Fourth+ Line(s): Grades for all students for one assignment, space delimited....

  • Write a C program to compute average grades for a course. The course records are in...

    Write a C program to compute average grades for a course. The course records are in a single file and are organized according to the following format: Each line contains a student’s first name, then one space, then the student’s last name, then one space, then some number of quiz scores that, if they exist, are separated by one space. Each student will have zero to ten scores, and each score is an integer not greater than 100. Your program...

  • ****THIS IS A 2 PART QUESTION! I ONLY NEED THE ANSWER TO PART 2 ON HOW...

    ****THIS IS A 2 PART QUESTION! I ONLY NEED THE ANSWER TO PART 2 ON HOW TO SEND THE DATA SERIALIZED**** Write a c# program that stores student grades in a text file and read grades from a text file.  The program has the following GUI: There are four buttons: Create File, Save Case, Close File and Load File.  Initially, only the Create File and Load File buttons are enabled.  If the user clicks the Create File button, a Save File Dialog window...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT