array
array
#include <iostream>
using namespace std;
int main() {
int numbers[5] = {10, 20, 30, 40, 50};
cout << "One-Dimensional Array Elements:" << endl;
for (int i = 0; i < 5; i++) {
cout << "numbers[" << i << "] = " << numbers[i] <<
endl;
}
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main() {
// Declare and initialize an array of strings
string fruits[3] = {"Apple", "Banana", "Cherry"};
return 0;
}
#include <iostream>
using namespace std;
int main() {
int size;
return 0;
}
int main() {
// 1. Declare and initialize a 2D array
int array[3][3] = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};
// 2. Display the 2D array elements
cout << "2D Array Elements:" << endl;
for (int i = 0; i < 3; i++) { // Iterate over rows
for (int j = 0; j < 3; j++) { // Iterate over
columns
cout << array[i][j] << " ";
}
cout << endl; // Move to the next line after each
row
}
return 0;
}