0

C++ arrays

I need to learn C++ so I can start working at a company, but the problem I have is, I just don't get it? a specially the Arrays. could someone help me out a bit?

15th Feb 2017, 10:50 AM
Justin Mangano
Justin Mangano - avatar
5 ответов
+ 16
An array is a collection of data, like integers or string. It is like on any other languages. In Python there are 4 types of array, but the arrays in C++ are more simple. For dxample let's say we have an arra called myArray. Firstly, we ahould declare the size of it, lets say 3. It means that there are 3 pieces of data in it. It is actually like a memory. Then we say myArray[0] = 4. The first value in myArray is going to be 4. They are really useful in loops. Hope you understand it. Yes, you can use Youtube if you still struggle. ;)
15th Feb 2017, 7:51 PM
Gami
Gami - avatar
+ 8
// declaring an integer array of size 5 int my_array[5]; // assigning values to array my_array[0] = 1; my_array[3] = 2; // these can then be used like a normal variable cout << my_array[0] // outputs 1 // Note: the index of an array starts from 0. // Hence e.g. array size 5 has index values ranging from 0 to 4. // arrays are usually utilised with loops for initiation purposes.
15th Feb 2017, 11:59 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
maybe i should just go on Youtube?
15th Feb 2017, 10:50 AM
Justin Mangano
Justin Mangano - avatar
0
in youtube you can refer to The NEW BOSTON channel
16th Feb 2017, 5:44 PM
Kaushik Roy
Kaushik Roy - avatar
0
an array can store collection of data.... you can also save data as tables, like Rows, Columns..... 1. first you have to declare data type of your array in which you want to save data.... like int, double, float etc... 2. then name of array with brackets [ ] like if you want an array of table then it will be like table[ ] no sapce between array's name and its brackets... it will save your data in only one row..... mean to say is first brackets stores data in rows [rows] in array...... it is also called as one dimention array... 3. if you want to save data in rows and columns then you have to write two pairs of brackets....[ ] [ ] first [numbers_to_make_Rows] second [number_to_make_columns] in these brackets first it will make a rows how much numbers you entered in first bracket then according to second it will break first row into pieces (according to your number that is given in second brackets..) those pieces will be called as columns..... it is called two dimention array....
21st Feb 2017, 9:37 AM
Sohaib Manzoor
Sohaib Manzoor - avatar