write a program that will calculate the average of the total marks scored by 10 students, if each student has done 4 exams.

Steve Steve answered
5 years ago

int scores[10,4],sum,s,i

real avg
sum=0
for s=1..10
print "Enter the 4 scores for student #",s,": "
read scores[s,i] for i=1..4
for i=1..4 sum += scores[s,i]
next s
avg = sum/40

Step-by-Step Bot Step-by-Step Bot answered
8 months ago

Sure! Here is a step-by-step guide to write a program that calculates the average of the total marks scored by 10 students, assuming each student has done 4 exams:

Step 1: Initialize variables
- Create a variable to store the total number of students (e.g., `num_students`) and set it to 10.
- Create a variable to store the total number of exams (e.g., `num_exams`) and set it to 4.
- Create a two-dimensional list or array to store the marks of each student for each exam (e.g., `marks`).

Step 2: Input marks
- Use a loop to iterate over the number of students.
- For each student, use another loop to iterate over the number of exams.
- Prompt the user to input the marks for each exam and store them in the `marks` list.

Step 3: Calculate the total marks
- Create an empty list to store the total marks of each student (e.g., `total_marks`).
- Using nested loops, iterate over the `marks` list and calculate the total marks for each student by summing up all the exam marks.
- Store the total marks for each student in the `total_marks` list.

Step 4: Calculate the average marks
- Calculate the sum of the total marks from all students using the `sum()` function and store it in a variable (e.g., `total_sum`).
- Divide the `total_sum` by the total number of students (`num_students` multiplied by `num_exams`) to calculate the average marks (e.g., `average_marks`).

Step 5: Display the average marks
- Print the calculated average marks.

Here is an example program in Python:

```python
num_students = 10
num_exams = 4
marks = []

# Input marks for each student and each exam
for i in range(num_students):
student_marks = []
print(f"Enter marks for student {i + 1}:")
for j in range(num_exams):
exam_mark = int(input(f"Enter marks for exam {j + 1}: "))
student_marks.append(exam_mark)
marks.append(student_marks)

# Calculate total marks for each student
total_marks = []
for student in marks:
total_marks.append(sum(student))

# Calculate average marks
total_sum = sum(total_marks)
average_marks = total_sum / (num_students * num_exams)

# Display the average marks
print(f"The average marks scored by {num_students} students in {num_exams} exams is: {average_marks}")
```

You can run this program and input the marks for each student and exam to calculate the average marks scored by the students.

Explain Bot Explain Bot answered
8 months ago

To calculate the average of the total marks scored by 10 students, with each student taking 4 exams, you can write a program in any programming language of your choice. Here's an example in Python:

```python
# Initialize variables
total_marks = 0
num_students = 10
num_exams = 4

# Iterate over each student
for student in range(num_students):
# Initialize student total marks
student_total_marks = 0

# Input marks for each exam
for exam in range(num_exams):
marks = int(input(f"Enter marks for student {student+1}, exam {exam+1}: "))
student_total_marks += marks

# Add student's total marks to the overall total marks
total_marks += student_total_marks

# Calculate the average marks
average_marks = total_marks / (num_students * num_exams)

# Print the average marks
print(f"The average marks scored by {num_students} students in {num_exams} exams is {average_marks}.")
```

You can run this program and input marks for each student and exam. At the end, it will calculate and display the average marks scored by the 10 students in 4 exams.

🤔 🤔 Ask a New Question 🤔 🤔