- 1
What is array
3 Antworten
+ 2
Arrays are used to declare group of variable of same data type.
Suppose you want to declare 10 integers , you can do it like
int a , b , ........
With use of arrays you can declare it in one line
int a[10];
Hope this helps ☺️☺️.
+ 1
This is basic info about arrays.
For more info you can refer lessons.
+ 1
ever saw those recycling bins for there by the side of the road marked with different colors? e,g red bottles, green bottles, green plastic etc... well think of that when thinking of arrays... you have that container for storing all the red bottles, container for green bottles and container for green plastic. no need for a box for storing each red bottle...
In arrays our containers are datatypes, the int, the string, the bool, you name them. instead of you going for boxes for each bottle, a variable in our case we go for a container, an array in our case.
ever came across multiple if statements? how do you minimize your work for them? Switch statement right? same thing as your arrays and variables.
Arrays are like our containers and inside of them they are sorted. A cargo container having clothes won't just clothes thrown all of over, you will definitely find them sorted jeans shirts and all. with arrays they are sorted in positions. Take note of this and make this your breakfast: Their starting positions start at 0 instead of 1 so when you have 3 boxes and you wanna chose the 2nd box that you see with your naked eyes, you refer to that box as box[1], why you do that is because of the position of the first in arrays is position 0. Tadaaa!