Challenge: Why Do We Need Array Size as an Argument?
Завдання
Swipe to start coding
You are creating a student analytics tool that calculates the average score from a list of grades stored in a dynamic array.
- The function
calculateAveragetakes a pointer to an integer arrayscoresand anintnrepresenting the number of elements. - Initialize a variable
sumto0before the loop. - Use a loop to iterate over the array from
0ton. - In each iteration, add the current element to the variable
sum. - Return the average score by dividing
sumbyn.
Example
{80, 90, 75, 85, 100} => 86.0
{60, 70, 80} => 70.0
{100, 90, 95, 85} => 92.5
Рішення
solution.cpp
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 6
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Awesome!
Completion rate improved to 5
Challenge: Why Do We Need Array Size as an Argument?
Свайпніть щоб показати меню
Завдання
Swipe to start coding
You are creating a student analytics tool that calculates the average score from a list of grades stored in a dynamic array.
- The function
calculateAveragetakes a pointer to an integer arrayscoresand anintnrepresenting the number of elements. - Initialize a variable
sumto0before the loop. - Use a loop to iterate over the array from
0ton. - In each iteration, add the current element to the variable
sum. - Return the average score by dividing
sumbyn.
Example
{80, 90, 75, 85, 100} => 86.0
{60, 70, 80} => 70.0
{100, 90, 95, 85} => 92.5
Рішення
solution.cpp
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 6
single