write a C++ program to accept and display two dimensional array
Answers
Answered by
55
Explanation:
- Declare one 2D array.
- Declare two variables for loop iteration.
- Create two nested loops for data insertion.
- Finally, display the data using two nested loops.
Program:
#include <iostream>
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;
}
#answerwithquality
#BAL
Attachments:

Answered by
2
Answer:
Explanation:
Hi
Similar questions