This document discusses different ways of declaring and initializing arrays in C++, including one-dimensional and two-dimensional arrays. It shows how to declare arrays with explicit sizes and initialize some or all elements, access individual elements, and use a for loop to iterate through elements. Garbage values that may occur when not initializing elements are also demonstrated.
This document discusses different ways of declaring and initializing arrays in C++, including one-dimensional and two-dimensional arrays. It shows how to declare arrays with explicit sizes and initialize some or all elements, access individual elements, and use a for loop to iterate through elements. Garbage values that may occur when not initializing elements are also demonstrated.
This document discusses different ways of declaring and initializing arrays in C++, including one-dimensional and two-dimensional arrays. It shows how to declare arrays with explicit sizes and initialize some or all elements, access individual elements, and use a for loop to iterate through elements. Garbage values that may occur when not initializing elements are also demonstrated.
int main() { // int A[10]; // A[0] = 20; // for (int i = 0; i < 10; i++) // cout<<A[i]<<endl; //garbage values are stored in all the elements except for the first one
// int B[5] = {34, 55, 76, 26, 49};
// cout<<B<<endl; //it won't print the whole array, it will print the address of the array (of the first element) // cout<<&B[0]<<endl;
// // ##1 Different ways of DECLARATION and array
// int C[] = {2, 4, 6, 8}; //array of size 4 is created
// int D[5] = {45, 957}; // all elements are of similar datatype // int E[5] = {34, 55, 76, 26, 49}; // int F[10]; // cout<<sizeof(C)<<endl; // cout<<D[1]<<endl; // cout<<D[4]<<endl;