Accessing array elements In Hindi
C++ प्रोग्रामिंग लैंग्वेज में यूजर डिफाइन ऐरे एलिमेंट्स डाटा वैल्यू को उनके स्टोरेज लोकेशन से इंडेक्सिंग ऑपरेटर [] का यूज़ करके एक्सेस और मैनेज किया जाता है। हमेशा याद रखे किसी भी स्टोर्ड C++ ऐरे एलिमेंट का स्टार्टिंग इंडेक्स लोकेशन डिफ़ॉल्ट 0 से स्टार्ट होता है, इसका मतलब है कि प्रोग्राम में डिक्लेअर फर्स्ट ऐरे एलिमेंट इंडेक्स 0 लोकेशन पर लोकेटेड या स्टोर्ड है. इसी सीक्वेंस में सेकंड ऐरे एलिमेंट इंडेक्स 1 लोकेशन पर लोकेटेड या स्टोर्ड है, और इसी प्रकार कॉन्टिनियस सीक्वेंस में अन्य ऐरे एलिमेंट यूजर डिफाइन ऐरे में रिप्रेजेंट और स्टोर्ड होते है।

syntax of accessing array elements in C++.
array_name[index];
Element of accessing array elements in C++.
- array_name – यह मौजूदा प्रोग्राम में यूजर डिफाइन डिक्लेअर ऐरे का नाम होता है।
- index – यह डिक्लेअर उस ऐरे एलिमेंट का इंडेक्स स्टोरेज ऐरे (पोजीशन) लोकेशन है. जिसे आप मौजूदा प्रोग्राम में उसकी इंडेक्स लोकेशन से एक्सेस करना चाहते हैं।
Accessing and Printing Array Elements in C++.
तो चलिए C++ प्रोग्रामिंग लैंग्वेज में हम एक सिंपल ऐरे को डिक्लेयर या डिफाइन कर उनकी डिफ़ॉल्ट स्टोरेज वैल्यू के साथ इनिशियलाइज़ करके उन्हें स्टार्ट करते हैं. इसके बाद हम प्रत्येक ऐरे एलिमेंट को जरूरत के अनुसार एक्सेस और प्रिंट कर सकते हैं।
Example of accessing array elements in C++.
#include <iostream>
using namespace std;
int main() {
// here we Declare a one-dimensional array and initialize an with array element
int array[5] = {9, 11, 200, 40, 22}
// here we Access and print the individual aray elements value
cout << “First Array Element index location 0 is – ” << array[0] << endl; // Result – 9
cout << “Second Array Element index location 1 is – ” << array[1] << endl; // Result – 11
cout << “Third Array Element index location 2 is – ” << array[2] << endl; // Result – 200
cout << “Fourth Array Element index location 3 is – ” << array[3] << endl; // Result – 40
cout << “Fifth Array Element index location 4 is – ” << array[4] << endl; // Result – 22
return 0;
}
Explanation of accessing array elements in C++.
- यहां इस एक्साम्प्ल में, ऐरे array को {9, 11, 200, 40, 22}; वैल्यू के साथ डिफ़ॉल्ट इनिशियलाइज़ किया गया है, और यहाँ हम हर ऐरे एलिमेंट को उनके रिलेटेड स्टोरेज इंडेक्स लोकेशन (0 से 4) का यूज़ करके वन बाय वन एक्सेस कर सकते हैं।
Modifying C++ Array Elements.
C++ ऐरे प्रोग्राम में यूजर किसी स्पेसिफिक स्पेशल ऐरे इंडेक्स को एक नई वैल्यू असाइन या प्रोवाइड करके मौजूदा ऐरे के एलिमेंट वैल्यू को मॉडिफ़ाई कर सकते हैं. इस प्रोसेस में ऐरे इंडेक्स लोकेशन का यूज़ कर ऐरे एलिमेंट को मॉडिफाई या रिप्लेस किया जाता है, न की उस ऐरे की इंडेक्स लोकेशन को।
Example of Modifying C++ Array Elements.
#include <iostream>
using namespace std;
int main() {
// here we Declare a one dimensional and initialize its array
int array[5] = {300, 400, 500, 799, 900};
// here we Modify the fourth array element (index 3) location
array[3] = 1000;
// here we Access and print the modified array element value
cout << “Preview of Modified fourth element (index 3) location at – ” << array[3] << endl; // Result is – 1000
// here it Print the entire array after array 4th modification value
for (int p = 0; p < 5; p++) {
cout << “Each Array Element stored at index location ” << p << ” – ” << array[p] << endl;
}
return 0;
}
Explanation of Modifying C++ Array Elements.
- यहाँ इस एक्साम्प्ल में स्टोर्ड फोर्थ ऐरे एलिमेंट (इंडेक्स 3) की वैल्यू 799 से 1000 वैल्यू से अपडेट किया गया है।
Accessing and Printing 2D Array Elements in C++.
तो चलिए हम एक 2d ऐरे में एलिमेंट को डिक्लेअर कर इंडिविजुअल ऐरे एलिमेंट को रौ एंड कॉलम आर्डर में स्टोरेज इंडेक्स लोकेशन से एक्सेस कर उसके रिजल्ट को डिस्प्ले करे.
Example of 2D Array Elements print in C++.
#include <iostream>
using namespace std;
int main() {
int array[3][4] = {
{9, 3, 1, 2},
{4, 8, 6, 5},
{11, 21, 31, 23}
};
// here we Accessing a specific array element using their storage location
cout << “Element of stored array index location is [1][1] = ” << array[1][1] << endl;
cout << “Element of stored array index location is [2][3] = ” << array[2][3] << endl;
cout << “\n Element of 2-Dimensional Array!\n”;
for (int p = 0; p < 3; p++) {
for (int q = 0; q < 4; q++) {
cout << array[p][q] << ” “;
}
cout << endl;
}
return 0;
}
Explanation of 2D Array Elements print in C++.
- यहाँ इस एक्साम्प्ल में हम एक 2 डायमेंशनल ऐरे जिसमे 3 रौ और 4 कॉलम वैल्यू को स्टोर कर उसके पर्टिकुलर इंडेक्स ऐरे लोकेशन एलिमेंट को डिस्प्ले करते है. जिसमे array[1][1] रौ 1 और कॉलम 1 में सेकंड ऐरे इंडेक्स लोकेशन एलिमेंट को डिस्प्ले किया गया है.
Accessing and Printing 3D Array Elements in C++.
तो चलिए हम एक 3d ऐरे में एलिमेंट को डिक्लेअर कर इंडिविजुअल मैट्रिक्स मल्टी-डायमेंशनल ऐरे एलिमेंट को रौ एंड कॉलम आर्डर में स्टोरेज इंडेक्स लोकेशन से एक्सेस कर उसके रिजल्ट को डिस्प्ले करते है.
Example of 3D Array Elements print in C++.
#include <iostream>
using namespace std;
int main() {
int array[2][3][4] = {
{
{77, 66, 55, 44},
{33, 22, 11, 10},
{10, 9, 8, 7}
},
{
{25, 27, 29, 30},
{33, 77, 99, 44},
{79, 34, 73, 87}
}
};
// here we Accessing a specific desire 3d array element stored location
cout << “Default Element storage location at array[1][1][3] = ” << array[1][1][3] << endl;
cout << “\n List 3D Array Elements Data\n”;
for (int p = 0; p < 2; p++) {
cout << “Structure of 3D Array ” << p << “!\n”;
for (int q = 0; q < 3; q++) {
for (int r = 0; r < 4; r++) {
cout << array[p][q][r] << ” “;
}
cout << endl;
}
cout << endl;
}
return 0;
}
Explanation of 3D Array Elements print in C++.
- यहाँ इस एक्साम्प्ल में हम एक 3 डायमेंशनल मैट्रिक्स ऐरे जिसमे array[2][3][4] कॉलम वैल्यू को स्टोर कर उसके पर्टिकुलर मैट्रिक्स इंडेक्स ऐरे लोकेशन एलिमेंट को डिस्प्ले करते है. जिसमे array[1][1][3] ऐरे इंडेक्स लोकेशन एलिमेंट को डिस्प्ले किया गया है.
