Question
Using the nested loop in C++ to finish the program

//test scores. //It asks the user for the // number of students and //the number of test scores //per student. // Calc. and display average score // for each TEST 2 4 6 7
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

#include <string>

using namespace std;

int main()

{

int score, total = 0, n , noOfTestScore;

cout<<"Enter the number of student: ";

cin>>n;

cout<<"Enter the number of Test Score: ";

cin>>noOfTestScore;

int arr[n][noOfTestScore];

for(int i=0 ; i<n ; ++i){

for(int j = 0 ; j<noOfTestScore; ++j){

cout<<"Enter a score: ";

cin>>arr[i][j];

}

}

float avg = 0;

for(int i=0 ; i<noOfTestScore ; ++i){

avg = 0;

for(int j = 0 ; j<n; ++j){

avg = avg + arr[j][i];

}

cout<<"Avg for Test #"<<(i+1)<<" : "<<avg/n<<endl;

}

}





=====================
See Output

main.cpp 日 っsaved gcc version 4.6.3 cin>>n; cout<<Enter the number of Test Score: ; cin»>no0fTestScore; int arr[n [no0fTestScore]; Enter the number of student: 4 Enter the number of Test Score: 3 Enter a score:2 Enter a score: 2 Enter a score: 2 Enter a score: 3 Enter a score: 3 Enter a score: 3 Enter a score: 4 Enter a score 4 Enter a score: 4 Enter a score: 5 Enter a score 5 Enter a score: 5 Avg for Test #1 t 3.5 Avg for Test #2 : 3.5 Avg for Test #3 3.5 5 10 12 13 for(int i-0in+i) 14 15 16 17 18 19 20 21 for(int i-0 ino0fTestScore+i)( for( int j 0 ; j«n00fTestScore ; ++]){ 5 cinarr[i]lj]; cout<<Enter a scor: 1 float avg = 0; avg0; for(int j-0; j<n; ++j 23 24 25 26 27 28 29 30 31 32 avg-avg + arr[j][i]; cout«СAvg for Test #<<(1+1)<< : <<avg/n««endl;
Thanks, PLEASE UPVOTE

Add a comment
Know the answer?
Add Answer to:
Using the nested loop in C++ to finish the program //test scores. //It asks the user...
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
  • Question: - write a C++ program that asks user to enter students' quiz scores, calculate the...

    Question: - write a C++ program that asks user to enter students' quiz scores, calculate the total score for each students and average for all. Note: - number of students: 1 through 5. That is, at least one student and up to 5. - number of quizes: 8 through 10. That is, at least 8 quizes and up to 10. - quiz score range: 0 through 100. - when entering quiz scores, if user enters -1, that means the user...

  • Small Basic Programming Question: Average Score- Write a program that uses loop to collect data and...

    Small Basic Programming Question: Average Score- Write a program that uses loop to collect data and calculate the average score over a number of tests for a number of students. The program should: 1. first ask the user to enter the number of students in the range of 1 to 10. 2. then the program asks the user to enter the number of tests (in the range of 1 to 5) 3. Then use a loop to collect the scores...

  • convert pseducode to c++ Starting out with Programming Logic and Design (3) - Read-only Terates once...

    convert pseducode to c++ Starting out with Programming Logic and Design (3) - Read-only Terates once for each student. The nested inner loop, in lines 27 through 31, iterates once for each test score. Program 5-20 1 1 This program averages test scores. It asks the user for th 2 1/ number of students and the number of test scores per stude Declare Integer numStudents 4 Declare Integer numTest Scores 5 Declare Integer total 6 Declare Integer student 7 Declare...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks 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’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • Small Basic Programming Question: Average score Write a program that uses loops to collect data and...

    Small Basic Programming Question: Average score Write a program that uses loops to collect data and calculate the average score over a number of tests for a number of students. The program should : 1. first ask the user to enter the number of students in the range of 1 to 10. 2. then the program asks the user to enter the number of tests (in the range of 1 to 5) 3. Then use a loop to collect the...

  • Write a program that asks the user to enter five test scores. The program should display...

    Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Design the following functions in the program: calcAverage—This function should accept five test scores as arguments and return the average of the scores. determineGrade—This function should accept a test score as an argument and return a letter grade for the score (as a String), based on the following grading scale: Score Letter Grade...

  • In this assignment, you will write a program in C++ which uses files and nested loops...

    In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...

  • [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and...

    [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and methods must be used for this program. Process: •Read the number of students in a class. Make sure that the user enters 1 or more students. •Create an array with the number of students entered by the user. •Then, read the name and the test score for each student. •Calculate the best or highest score. •Then, Calculate letter grades based on the following criteria:...

  • C++ 4. Write a program that inputs 5 scores using a do while loop and asks...

    C++ 4. Write a program that inputs 5 scores using a do while loop and asks a user whether to continue or not ("yes" or "no il pressed you continues if pressed no' terutiinales) then calculates the average. 5. Make a program calculates sales for its division and quarterly earnings and show the total sum. Use 5 by 2 array matrix 6. This is an extra credil questioni Produce a program that displays by decreasing or decremeniting by 4 starting...

  • Create a C++ program to calculate grades as well as descriptive statistics for a set of...

    Create a C++ program to calculate grades as well as descriptive statistics for a set of test scores. The test scores can be entered via a user prompt or through an external file. For each student, you need to provide a student name (string) and a test score (float). The program will do the followings: Assign a grade (A, B, C, D, or F) based on a student’s test score. Display the grade roster as shown below: Name      Test Score    ...

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
ADVERTISEMENT