0

Why we are usig array?

21st Oct 2016, 2:24 AM
vignesh
4 Antworten
+ 1
as opposed to a list? I'm not sure what you're asking
21st Oct 2016, 5:31 AM
Zeke Williams
Zeke Williams - avatar
+ 1
Arrays can store multiple values for a dataset. See it as a variable containing more than one number. ie List[5] = {1,2,3,4,5}; //these 5 values are stored Now remember array "place holders" start counting from 0. So cout<< List[0]; //this would display 1 cout<< List[1]; //this would display 2 cout<< List[2]; //this would display 3 cout<< List[3]; //this would display 4 cout<< List[4]; //this would display 5 To display the entire list you have to use a for-loop for(int i=0; i<5; i++) { cout<<List[i]<<endl; //endl means newline } Output: 1 2 3 4 5
23rd Oct 2016, 2:16 PM
Cilliers Naude
0
to use multiple numbers and not just one number or variable. Think of an array as a list
22nd Oct 2016, 4:11 AM
vinod nair
vinod nair - avatar
0
you could imagine that in case of : x [5]; x is the shopping list with 5 items in it. But you must only remember where is the bloody shopping list 😊
27th Oct 2016, 10:29 AM
Andreas Kretzschmar
Andreas Kretzschmar - avatar