Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Manipulations with Arrays | Intro to Arrays
Introduction to C++ | Mobile-Friendly

bookManipulations with Arrays

You can also use for loops in arrays to find the sum of all elements:

12345678
int numbers[4] = {42, 12, 56, 98}; int sum = 0; for (int i = 0; i <= 3; i++) { &nbsp;&nbsp;&nbsp;&nbsp; sum += numbers[i]; } cout << sum;
copy

Here the variable sum will store the sum of all elements, initially, it’s equal to 0. Then we iterate through the array using for loops and add each element to the variable sum.

You can also store in arrays the data from the user:

int numbers[4];
int sum = 0;

for (int i = 0; i <= 3; i++) {
    cout << "Type the number: ";
    cin >> numbers[i];
    sum += numbers[i];
}
question mark

What does the following code do?

for (int i = 0; i <= 9; i++) { mul *= numbers[i]; }

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 5. Розділ 3

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

Запитайте мені питання про цей предмет

Сумаризуйте цей розділ

Покажіть реальні приклади

Awesome!

Completion rate improved to 3.7

bookManipulations with Arrays

Свайпніть щоб показати меню

You can also use for loops in arrays to find the sum of all elements:

12345678
int numbers[4] = {42, 12, 56, 98}; int sum = 0; for (int i = 0; i <= 3; i++) { &nbsp;&nbsp;&nbsp;&nbsp; sum += numbers[i]; } cout << sum;
copy

Here the variable sum will store the sum of all elements, initially, it’s equal to 0. Then we iterate through the array using for loops and add each element to the variable sum.

You can also store in arrays the data from the user:

int numbers[4];
int sum = 0;

for (int i = 0; i <= 3; i++) {
    cout << "Type the number: ";
    cin >> numbers[i];
    sum += numbers[i];
}
question mark

What does the following code do?

for (int i = 0; i <= 9; i++) { mul *= numbers[i]; }

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 5. Розділ 3
some-alt