How do you write a program that accepts 5 integers in an array and shows the average of 3?

1 answer

Answer

1049545

2026-04-16 13:40

+ Follow

To write a program that accepts 5 integers in an array and calculates the average of the first three, you can follow these steps: First, create an array to hold the 5 integers. Then, prompt the user to input the integers and store them in the array. Finally, compute the average of the first three integers by summing them and dividing by 3, and display the result. Here’s a simple example in Python:

<code class="language-python">numbers = [int(input("Enter integer {}: ".format(i + 1))) for i in range(5)]

average = sum(numbers[:3]) / 3 print("Average of the first three integers:", average)

</code>
ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.