Untitled
plain_text
a month ago
773 B
0
Indexable
Never
#include <iostream> using namespace std; int main() { // Declare an integer array of size 5 int myArray[5]; // Initialize elements of the array myArray[0] = 10; myArray[1] = 20; myArray[2] = 30; myArray[3] = 40; myArray[4] = 50; // Access and print array elements for (int i = 0; i < 5; i++) { cout << "myArray[" << i << "] = " << myArray[i] << endl; } // int myArray[5] = {10, 20, 30, 40, 50}; // Initialize with values // int anotherArray[] = {1, 2, 3, 4, 5}; // Size automatically determined // char charArray[3] = {'a', 'b', 'c'}; // Character array // TRAVERSING THROUGH AN ARRAY //for (int i = 0; i < size; i++) { // cout << myArray[i] << " "; // } return 0; }