Two Dimensional array are used when we have complex and large records in a sequence in programming. We always need nested for loops to access the records in two dimensional arrays . These loops working in the sequence as , one loop run on the indexing of the array and the second on the records of the arrays.
Source Code
#include <iostream.h> int main() { int myArray[5][3] = { //Create Two'D Array {1,2,3}, //Initialize the Array with Integers {4,5,6}, {7,8,9}, {10,11,12}, {13,14,15} }; for(int i = 0; i<5; i++) // OutSide for Loop { cout<<endl; for (int j = 0; j < 3; j++) //Inner side for loop in which data of Two'D Display { cout<<"\t"<<myArray[i][j]; //Display the Array } } cout<<endl; return 0; }
0 comments:
Post a Comment