0

I don't understand the reason for using arrays in C++. Can someone explain?

I'm totally new to coding and am doing this for fun so I don't really get the idea of arrays and where/why they are useful?

27th Sep 2018, 2:17 PM
Tom Eckert
Tom Eckert - avatar
1 ответ
+ 2
Tom,Imagine you want to save in the computer memory 100 names of pepole.you have 2 options:declare 100 strings,or declare one array of 100 strings.the second option is much more easy to use and if you want to print all the names in the array,instead of writing: print(name1) print(name2) . . .(100 lines of code) (its in python cause i dont know c++ but its the same idea) or you can use a loop which will print all the names with only 2 lines of code! also,arrays are saved in the computer memory in an order ,for example,if the first item in the array is in place 8000 in the computer memory,the next item will be 8001,then 8002 and so on
27th Sep 2018, 4:21 PM
gil gil