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

bookChallenge: Array Statistics

Oppgave

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.

Løsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 4
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

close

bookChallenge: Array Statistics

Sveip for å vise menyen

Oppgave

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.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 4
single

single

some-alt