Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Array Statistics | Functions Returning Arrays & Refactoring Loops
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C# Methods & Modular Thinking

bookChallenge: Array Statistics

Task

Swipe to start coding

Write two methods to calculate statistics for an array of integers. The first method should return the sum of all elements in the array. The second method should return the average value of the array as a double.

  • The CalculateSum method must return the sum of all elements in the numbers array.
  • The CalculateAverage method must return the average of the elements in the numbers array as a double.
  • If the numbers array is empty, CalculateAverage must return 0.0.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 4
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookChallenge: Array Statistics

Swipe to show menu

Task

Swipe to start coding

Write two methods to calculate statistics for an array of integers. The first method should return the sum of all elements in the array. The second method should return the average value of the array as a double.

  • The CalculateSum method must return the sum of all elements in the numbers array.
  • The CalculateAverage method must return the average of the elements in the numbers array as a double.
  • If the numbers array is empty, CalculateAverage must return 0.0.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 4
single

single

some-alt