Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Challenge: Indexing | Arrays
C# Basics
course content

Cursusinhoud

C# Basics

C# Basics

1. Getting Started
2. Dealing with Data Types
3. Control Structures
4. Loops
5. Arrays
6. Methods

book
Challenge: Indexing

Find the mean between the largest and the smallest element of the numbers array.

Mean, also called average, represents the central number between two or more than two numbers. For example the mean value between 1 and 5 is 3.

Use indexing to access the smallest and the largest elements of the array.

cs

main

copy
1234567891011121314151617
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { int[] numbers = { 5, 9, 27, 17, 19, 21, 0, -7, 10 }; int sum = ___; int mean = ___; Console.WriteLine(mean); } } }
  1. The sum variable should contain the sum of the two values.
  2. Figure out the index of the smallest and the largest elements of the numbers array and access those elements via indexing (numbers[index]), then store their sum in the sum variable.
  3. The mean will be the sum divided by 2.
cs

main

copy
1234567891011121314151617
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { int[] numbers = { 5, 9, 27, 17, 19, 21, 0, -7, 10 }; int sum = numbers[2] + numbers[7]; int mean = sum / 2; Console.WriteLine(mean); } } }

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 5. Hoofdstuk 4
Onze excuses dat er iets mis is gegaan. Wat is er gebeurd?
some-alt