Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Fill Arrays | Data Types and Arrays
C++ Intermediate | Mobile-Friendly

bookFill Arrays

As you remember, by accessing elements of the array, we can not only print them but also change them. For instance:

12345678
int x[2][3] { &nbsp;&nbsp;&nbsp;&nbsp; {1, 2, 3},&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; {4, 5, 6} }; cout << x[0][0] << endl; x[0][0] = 100; cout << x[0][0];
copy

Actually, we may not only change elements of the existing array but also set values:

12345678910111213
int x[2][2]; x[0][0] = 1; cout << x[0][0] << " "; x[1][0] = 2; cout << x[1][0] << " "; x[0][1] = 3; cout << x[0][1] << " "; x[1][1] = 4; cout << x[1][1] << " ";
copy

Let's consolidate the acquired knowledge!

question-icon

Assign 42 to the first element in the second row of the array x and print it.

int x[3][2];
;
cout <<
;
42

Click or drag`n`drop items and fill in the blanks

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 7

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

Suggested prompts:

Still meg spørsmål om dette emnet

Oppsummer dette kapittelet

Vis eksempler fra virkeligheten

Awesome!

Completion rate improved to 2.94

bookFill Arrays

Sveip for å vise menyen

As you remember, by accessing elements of the array, we can not only print them but also change them. For instance:

12345678
int x[2][3] { &nbsp;&nbsp;&nbsp;&nbsp; {1, 2, 3},&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; {4, 5, 6} }; cout << x[0][0] << endl; x[0][0] = 100; cout << x[0][0];
copy

Actually, we may not only change elements of the existing array but also set values:

12345678910111213
int x[2][2]; x[0][0] = 1; cout << x[0][0] << " "; x[1][0] = 2; cout << x[1][0] << " "; x[0][1] = 3; cout << x[0][1] << " "; x[1][1] = 4; cout << x[1][1] << " ";
copy

Let's consolidate the acquired knowledge!

question-icon

Assign 42 to the first element in the second row of the array x and print it.

int x[3][2];
;
cout <<
;
42

Click or drag`n`drop items and fill in the blanks

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 7
some-alt