Write a c++ program to accept and display 2 dimensional array

4 views

1 Answers

#include

using namespace std;

int main()

{

   int array2d[3][3]; // 2D array declared

   int i, j; // variables for loop iteration

   

   cout << "Enter the elements for 2D array:" << endl;

   for(i = 0; i <= 2; i++)

   {

       for(j = 0; j <= 2; j++)

       {

           // inserting the elements in the 2D array

           cin >> array2d[i][j];

       }

   }

   

   cout << "Inserted elements in the 2D array:" << endl;

   for(i = 0; i <= 2; i++)

   {

       for(j = 0; j <= 2; j++)

       {

           cout << array2d[i][j] << " ";

       }

       cout << endl;

   }

   

   return 0;

}

4 views

Related Questions