Exercis Write a program that asks the user to enter how many students they have. Use a for loop to iterate through each student. For each student, allow the user to enter as many scores as they want and let them know that entering -1 will indicate the end of entering scores (note: use a while loop with sentinel value). Sum all the scores for each student and display the total on the screen For example:
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
![How many students? 2
Enter scores for student 1 (-1 to end):
I
56
45
99
-1
Total scores for Student 1 is (total calculated)
Enter scores for student 2 (-1 to end):
80
99
-1
Total scores for Student 2 is (total calculated) |](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff0e09b5a-756e-420a-abb6-b9d08421e768%2F890313d0-2030-4014-9355-18cfd2cdd1b7%2Fk8jz8kc_processed.png&w=3840&q=75)
![Class Exercise
Write a program that asks the user to enter how
many students they have. Use a for loop to
iterate through each student. For each student,
allow the user to enter as many scores as they
want and let them know that entering -1 will
indicate the end of entering scores (note: use a
while loop with sentinel value). Sum all the
scores for each student and display the total on
the screen. For example:
Student 1 Total score is 340
Student 2 Total score is 200](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff0e09b5a-756e-420a-abb6-b9d08421e768%2F890313d0-2030-4014-9355-18cfd2cdd1b7%2F85mo9j_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)