Please help, the tasks on last paragraph. Laboratory work No. 5 "Fundamentals of the C ++ programming language: Arrays" One-dimensional arrays It often becomes necessary to store not one variable, but a set of variables of the same type. For example, a list of students in a class is a string-type dataset, the coordinates of a polygon's vertices, or the coefficients of a polynomial is a numeric dataset. Data structures are used to store datasets. The main data structure is an array. An array is a structure of the same type of data that occupies a contiguous area of ​​memory. An array has size — the number of elements in it. Each element of an array has its own number (also called an index); an array element is accessed by specifying its index. In C ++, elements are numbered starting at 0, so the last element in an array is numbered 1 less than the size of the array. An array in C ++ is defined as follows: item_type id [size]; where_element_type is an arbitrary data type of the C ++ language that the elements of the array will have, for example, int, double, etc .; identifier is the name of the array, size is the number of elements in it. An array element can be accessed as an identifier [index]. For example, if an announcement was made doubleA [5]; then in this way 5 elements of a double array are created: A [0], A [1], A [2], A [3], A [4]. An example program that creates an array of type int [] of a user-specified size, reads its elements from the keyboard, then adds number 1 to each element of the array, and then displays the result on the screen: #include usingnamespacestd; intmain () { intn; // Array size inti; // counter in cycles cout << "Enter the number of numbers:"; cin >> n; // Read the size of the array intarr [n]; // Array declaration // Read the array cout << "Enter" << n << "integers:"; for (i = 0; i > arr [i]; // Add 1 to each element for (i = 0; i

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please help, the tasks on last paragraph.

Laboratory work No. 5 "Fundamentals of the C ++ programming language: Arrays"

One-dimensional arrays

It often becomes necessary to store not one variable, but a set of variables of the same type. For example, a list of students in a class is a string-type dataset, the coordinates of a polygon's vertices, or the coefficients of a polynomial is a numeric dataset. Data structures are used to store datasets. The main data structure is an array.

An array is a structure of the same type of data that occupies a contiguous area of ​​memory. An array has size — the number of elements in it. Each element of an array has its own number (also called an index); an array element is accessed by specifying its index. In C ++, elements are numbered starting at 0, so the last element in an array is numbered 1 less than the size of the array.

An array in C ++ is defined as follows:

item_type id [size];

where_element_type is an arbitrary data type of the C ++ language that the elements of the array will have, for example, int, double, etc .; identifier is the name of the array, size is the number of elements in it.

An array element can be accessed as an identifier [index]. For example, if an announcement was made

doubleA [5];

then in this way 5 elements of a double array are created: A [0], A [1], A [2], A [3], A [4].

An example program that creates an array of type int [] of a user-specified size, reads its elements from the keyboard, then adds number 1 to each element of the array, and then displays the result on the screen:

#include <iostream>
usingnamespacestd;
intmain ()
{
intn; // Array size
inti; // counter in cycles

cout << "Enter the number of numbers:";
cin >> n; // Read the size of the array

intarr [n]; // Array declaration

// Read the array
cout << "Enter" << n << "integers:";
for (i = 0; i <n; ++ i)
cin >> arr [i];

// Add 1 to each element
for (i = 0; i <n; ++ i)
arr [i] + = 1;

// Display the array on the screen
for (i = 0; i <n; ++ i)
cout << arr [i] << "";
// Translate the cursororn to a new string
cout << endl;
return0;
}

Tasks

Print all the even-indexed elements of the array (that is, A [0], A [2], A [4], ...).

Print all the even elements of the array (that is, those elements that are even numbers).

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education