1. Write the pseudo codes for the following: a. (Counter Controlled) A class of
ID: 3527284 • Letter: 1
Question
1. Write the pseudo codes for the following: a. (Counter Controlled) A class of ten students took a quiz. The grades (integers in the range 0 to 100) for this quiz are available to you. Calculate and display the total of all student grades and the class average on the quiz. The class average is equal o the sum of the grades divided by the number of students. The algorithm for solving this problem on a computer must input each of the grades, calculate the average and print the result. b. (Sentinel Controlled) Develop a class average program similar to (1-a) that process grades for an arbitrary number of students each time it is run. 2. Write C++ programs to do question 1Explanation / Answer
#include #include #define NAME_LEN 50 #define STUD_LEN 100 int read_line(char str[], int n); int find_students(int students); struct test_result { char name[NAME_LEN+1]; int number; int grade1; int grade2; int midterm; int final; float numeric; }studen[STUD_LEN]; void insert(void); void print(void); int num_students = 0; int main(void) { struct test_result test; printf("Enter the student's name: "); read_line(test.name, NAME_LEN); printf("Enter the student's grade for quiz #1: "); scanf("%d", &test.grade1); printf("Enter the student's grade for quiz #2: "); scanf("%d", &test.grade2); printf("Enter the student's grade for midterm: "); scanf("%d", &test.midterm); printf("Enter the student's grade for final: "); scanf("%d", &test.final); test.numeric = (((test.grade1 + test.grade2) * 1.25) + (test.midterm * 0.25) + (test.final * 0.50)); printf("%s's numeric score for the entire course is %.1f ", test.name, test.numeric); char code; for (;;) { printf(" "); printf("Would you like to enter another student record? y(yes) or n(no)?"); scanf(" %c", &code); while (getchar() != ' ') /* skips to end of line */ ; switch (code) { case 'y': insert(); break; case 'n': print(); return 0; default: printf("Invalid entry. Try again. "); return 0; } } } int find_students(int students) { int i; for (i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.