006-001-010
For Loop: Process Array Elements
Hard
Problem Description
for loop: Process array Elements
In this problem, you will create a program that iterates over all elements of an integer array using a for loop, outputs each element in order, and displays the total and average to standard output.
Learning Objective: Understand how to process all array elements using a for loop
Overview
Create a program that outputs all numbers in an array and calculates the total and average.
Specifications
- Initialize integer array
scoreswith values {85, 92, 78, 90, 88} - Use a for loop to output each element
- Calculate and output the total
- Calculate and output the average (1 decimal place)
Output Format
Score 1: 85
Score 2: 92
Score 3: 78
Score 4: 90
Score 5: 88
Total: 433
Average: 86.6
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up