Question

Make a program storing 5 student grades with each student to take 3 courses. the input...

Make a program storing 5 student grades with each student to take 3 courses. the input is from 0-100 score into 0-4 (GPA) in the array form. use c language

Score 1 Score 2 score 3 GPA
Std 1
std 2
std 3
std 4
std 5

Homework Answers

Answer #1

GPA calculation:

  • GPA = Average of scores / 10
  • Where Average of scores = (sum of scores / number of scores)

Code Explanation:

  • include the required libraries
  • declare the prototype of functions we use
  • In the main function declare 5 arrays with size3 and give the scores
  • To calculate GPA call the gpa function
  • The gpa() function calculates the gpa by summing all the scores. Dividing the sum by 3 and then by 10. and returns the GPA
  • Then print name of each column of the table
  • Then call print_table() function
  • Here the print_table function prints the student number and their respective scores and gpa in a table format

Code:

#include <stdio.h>
float gpa(float array[]);
int print_table(float ar1[],float GPA,int n);
int main()
{
float std1_scores[3] = {90.0,65.0,98.0};
float std2_scores[3] = {78,90.7,67.5};
float std3_scores[3] = {92.5,93.3,97.8};
float std4_scores[3] = {80.0,90.0,70.0};
float std5_scores[3] = {56.1,65.4,45.2};
float GPA1 = gpa(std1_scores);
float GPA2 = gpa(std2_scores);
float GPA3 = gpa(std3_scores);
float GPA4 = gpa(std4_scores);
float GPA5 = gpa(std5_scores);

printf("\t\tScore1\t\tScore2\t\tScore3\t\tGPA\n");
print_table(std1_scores,GPA1,1);
print_table(std2_scores,GPA2,2);
print_table(std3_scores,GPA3,3);
print_table(std4_scores,GPA4,4);
print_table(std5_scores,GPA5,5);

return 0;
}

float gpa(float std_scores[]){

float avg;
float sum = 0;

for(int i=0;i<3;i++){
sum = sum + std_scores[i];
}

avg = sum/3;
return(avg/10);

}
int print_table(float x[], float GPA, int n){


printf("std %d",n);
printf("\t\t%f\t%f\t%f\t%.1f\n",x[0],x[1],x[2],GPA);
return 0;
}

O/P:

Score1 Score2 Score3 GPA
std 1 90.000000 65.000000 98.000000 8.4
std 2 78.000000 90.699997 67.500000 7.9
std 3 92.500000 93.300003 97.800003 9.5
std 4 80.000000 90.000000 70.000000 8.0
std 5 56.099998 65.400002 45.200001 5.6

Code Screenshot:

O/P Screenshot:

Know the answer?
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
Similar Questions
A college student took 4 courses last semester. His final grades, along with the credits each...
A college student took 4 courses last semester. His final grades, along with the credits each class is worth, are as follow: A (4), B (3), C (3), and D (2). The grading system assigns quality points as follows: A: 4; B: 3; C: 2; D: 1; and F: 0. Find the student’s GPA for this semester. Round your answer to the nearest thousandth (three decimals).
Create a program named admission that takes as Input the student name, GPA and the admission...
Create a program named admission that takes as Input the student name, GPA and the admission Test Score, the application should display if the student got accepted or rejected. The program should use a function named AcceptOrReject( gpa, testScore) to control the program. Acceptance is based on the following criteria: The student can get accepted in the following two cases : 1- if the GPA is less than 3.0, the test score has to be more than 80 to get...
Write a program in MIPS ASSEMBLY LANGUAGE.. Take no of students as input from the user,...
Write a program in MIPS ASSEMBLY LANGUAGE.. Take no of students as input from the user, then take marks of 5 subjects for each student from the user. Then find Minimun, Maximum and Median of all the subjects. and comment each line in code also make flow chart
A student earned grades of Upper B​, Upper C​, Upper B​, Upper A​, and Upper C....
A student earned grades of Upper B​, Upper C​, Upper B​, Upper A​, and Upper C. Those courses had the corresponding numbers of credit hours 2​, 2​, 4​, 1​, and 3. The grading system assigns quality points to letter grades as​ follows: Aequals​4; Bequals​3; Cequals​2; Dequals​1; Fequals0. Compute the grade point average​ (GPA) as a weighted mean and round the result with two decimal places. If the​ Dean's list requires a GPA of 3.00 or​ greater, did this student make...
Create a program to calculate and print basic stats on a set of a given input...
Create a program to calculate and print basic stats on a set of a given input values representing students' scores on an quiz. 1) Ask the user for the total number of quiz scores to be input (assume a positive integer will be given). 2) Create an array to hold all the quiz scores and then get all the scores from input to put into the array. For example, if the user input 10 in step (1) then you should...
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’...
Functions displayGrades and addGrades must be rewritten so that the only parameters they take in are...
Functions displayGrades and addGrades must be rewritten so that the only parameters they take in are pointers or constant pointers. Directions: Using the following parallel array and array of vectors: // may be declared outside the main function const int NUM_STUDENTS = 3; // may only be declared within the main function string students[NUM_STUDENTS] = {"Tom","Jane","Jo"}; vector <int> grades[NUM_STUDENTS] {{78,98,88,99,77},{62,99,94,85,93}, {73,82,88,85,78}}; Be sure to compile using g++ -std=c++11 helpWithGradesPtr.cpp Write a C++ program to run a menu-driven program with the...
Write a C++ program. 1) Write a program that writes the grades for 3 students. Declare...
Write a C++ program. 1) Write a program that writes the grades for 3 students. Declare a variable of type ofstream which is used to output a stream into a file: ofstream output; // output is the name of the variable Prompt the user to input values for the grades of 3 students. Use the output operator (<<) to write the grades into grades.txt: output << grade1 << " " << grade2 << " " << grade3 << endl; You...
The following program allows the user to enter the grades of 10 students in a class...
The following program allows the user to enter the grades of 10 students in a class in an array called grade. In a separate loop, you need to test if a grade is passing or failing, and copy the grade to an array to store passing or failing grades accordingly. A passing grade is a grade greater than or equal to 60. You can assume the use will enter a grade in the range of 0 to 100, inclusive. ...
You are to write a program that will process students and their grades. For each student...
You are to write a program that will process students and their grades. For each student the program will read in a student’s name. It should also read in 10 test scores for the student and calculate his or her average. You must read the scores using a loop. The program should output the student’s name, average and letter grade. The average should be displayed accurate to 1 decimal digit. Letter grades are assigned based on the scale: 90-100    A...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT