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 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...
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...
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...
USE PYTHON LANGUAGE PLEASE FOCUS YOU SHOULD ENTER AN ARRAY AND THEN THE PROGRAM GIVE OUTPUT(...
USE PYTHON LANGUAGE PLEASE FOCUS YOU SHOULD ENTER AN ARRAY AND THEN THE PROGRAM GIVE OUTPUT( TRUE/ FALSE) QUIZ 8 Array Challenge Have the function ArrayChallenge(arr) take the array of numbers stored in arr and return the string true if any two numbers can be multiplied so that the answer is greater than double the sum of all the elements in the array. If not, return the string false. For example: if arr is [2, 5, 6, -6, 16, 2,...
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std;...
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std; int theArray[] = { 5, 11, -29, 45, 9, -1}; void sumPos(int ary[], int len, int &sum) {    sum = 0;    for (int i = 0; i < len; i++)            if (ary[i] > 0)                sum = sum + ary[i]; } int main() {    int total;    sumPos(theArray, 6, total);    for (int k=0; k < 6; k++)      cout...
write a program that automates the process of generating the final student report for DC faculty...
write a program that automates the process of generating the final student report for DC faculty considering the following restrictions. Consider declaring three arrays for processing the student data: studID studName studGrade The student ID is a random number generated by the 5-digit system in the range of (10000 - 99999). Create a function to assign the student ID generated in an array of numbers. Consider the following to generate the random number: Add the libraries: #include <stdlib.h> #include <ctime>...
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF...
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF A RUNNING COMPILER QUESTION: 1) Fibonacci sequence is a sequence in which every number after the first two is the sum of the two preceding ones. Write a C++ program that takes a number n from user and populate an array with first n Fibonacci numbers. For example: For n=10 Fibonacci Numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 2): Write...
Write a program in ARM assembly language that copies each element of array A to consecutive...
Write a program in ARM assembly language that copies each element of array A to consecutive fourth elements of array B, i.e., A[0] to B[0], A[1] to B[3], A[2] to B[7], etc. The array A is 12 elements long, and each element is a number that is 32 bits (1 word) wide. Assume the base address of array A is in register R2, and the base address of array B is in R3.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT