Introduction
In this challenge, you'll demonstrate your understanding of array initialization and manipulation by creating a program to track student performance in a programming class. You'll need to create an integer array to store 5 student scores, initialize the array with scores between 70 and 100, use a for loop to print each student's score, and calculate and display the average score of the class.
Create and Manipulate Student Scores Array
In this challenge, you'll demonstrate your understanding of array initialization and manipulation by creating a program to track student performance in a programming class.
Tasks
- Create an integer array to store 5 student scores
- Initialize the array with scores between 70 and 100
- Use a for loop to print each student's score
- Calculate and display the average score of the class
Requirements
- Create the file
~/project/student_scores.cpp - Use C++ as the programming language
- Declare an integer array with exactly 5 elements
- Initialize scores manually with values between 70 and 100
- Use a
forloop to print individual scores - Calculate the average score using integer division
- Print the average score with two decimal places using
static_cast<double>
Examples
Compile and run the program:
g++ student_scores.cpp -o student_scores
./student_scores
If the program is implemented correctly, it should display the student scores and average score.
Example output:
Student Scores:
Score 1: 85
Score 2: 92
Score 3: 78
Score 4: 95
Score 5: 88
Average Score: 87.60
Hints
- Remember array indices start at 0
- Use
static_cast<double>()to convert integer to floating-point for average calculation - Use
std::coutto print scores and average
Summary
In summary, this challenge requires you to create a program that initializes an integer array with 5 student scores between 70 and 100, print each student's score using a for loop, and calculate and display the average score of the class.



