DVE
9
Q:

define array in c++

string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"};
18
int foo[5] = {0};
1
int foo [] = { 16, 2, 77, 40, 12071 };
9
// Array declaration by specifying size and initializing 
// elements 
int arr[6] = { 10, 20, 30, 40 } 
  
// Compiler creates an array of size 6, initializes first 
// 4 elements as specified by user and rest two elements as 0. 
// above is same as  "int arr[] = {10, 20, 30, 40, 0, 0}" 
4
int foo [5];
0
// Array declaration by initializing elements 
int arr[] = { 10, 20, 30, 40 } 
  
// Compiler creates an array of size 4. 
// above is same as  "int arr[4] = {10, 20, 30, 40}" 
0
int foo[] = { 10, 20, 30 };
int foo[] { 10, 20, 30 }; 
0
int bar [5] = { 10, 20, 30 };  
0
// datatype var_name[howmuch value you need to store] = {values, values}
int a[5] = {1, 2 3, 4, 5};
0

New to Communities?

Join the community