Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

An array is a collection of variables of the same type that are referred to by a common name. To declare a one-dimensional array, you

An array is a collection of variables of the same type that are referred to by a common name. To declare a one-dimensional array, you will use this general form:

type[ ] array-name = new type[size];

using System;

class MainClass {

public static void Main() {

int[] sample = new int[10];

int i;

for(i = 0; i < 10; i = i+1) sample[i] = i;

for(i = 0; i < 10; i = i+1)

Console.WriteLine("sample[" + i + "]: " +

sample[i]); } }

The general form for initializing a one-dimensional array is shown here:

type[ ] array-name = { val1, val2, val3, ..., valN };

using System;

class MainClass {

public static void Main() {

int[] nums = { 99, 10, 100, 18, 78, 23, 63, 9, 87, 49 };

int avg = 0;

for(int i=0; i < 10; i++)

avg = avg + nums[i];

avg = avg / 10;

Console.WriteLine("Average: " + avg); } }

Output:

Average 53

Assignment : Based on the examples, please create a code that initialize one dimensional array with the following set of numbers {45, 76, 8, 10, 34, 66, 87, 90, 13,26.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

3. Who would the members be?

Answered: 1 week ago

Question

4. Who would lead the group?

Answered: 1 week ago