Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Why Do We Need Array Size as an Argument? | Function Arguments Specification
C++ Functions

bookChallenge: 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.

  1. The function calculateAverage takes a pointer to an integer array scores and an int n representing the number of elements.
  2. Initialize a variable sum to 0 before the loop.
  3. Use a loop to iterate over the array from 0 to n.
  4. In each iteration, add the current element to the variable sum.
  5. Return the average score by dividing sum by n.

Example

{80, 90, 75, 85, 100} => 86.0
{60, 70, 80} => 70.0
{100, 90, 95, 85} => 92.5

Рішення

solution.cpp

solution.cpp

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 6
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

close

Awesome!

Completion rate improved to 5

bookChallenge: 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.

  1. The function calculateAverage takes a pointer to an integer array scores and an int n representing the number of elements.
  2. Initialize a variable sum to 0 before the loop.
  3. Use a loop to iterate over the array from 0 to n.
  4. In each iteration, add the current element to the variable sum.
  5. Return the average score by dividing sum by n.

Example

{80, 90, 75, 85, 100} => 86.0
{60, 70, 80} => 70.0
{100, 90, 95, 85} => 92.5

Рішення

solution.cpp

solution.cpp

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 6
single

single

some-alt