Fill a two dimensional integer array element by element : multi dimension array « Array « C++ Tutorial






#include <iostream>
using namespace std;
int main()
{
     int monthlytemps[4][7];
     cout << "Enter the temp for week 1 day 1";
     cin >> monthlytemps[0][0];
     cout << "Enter the temp for week 1 day 2";
     cin >> monthlytemps[0][1];
     cout << "Enter the temp for week 1 day 3";
     cin >> monthlytemps[0][2];
     cout << "Enter the temp for week 1 day 4";
     cin >> monthlytemps[0][3];
     cout << "Enter the temp for week 1 day 5";
     cin >> monthlytemps[0][4];
     cout << "Enter the temp for week 1 day 6";
     cin >> monthlytemps[0][5];
     cout << "Enter the temp for week 1 day 7";
     cin >> monthlytemps[0][6];
     cout << "Enter the temp for week 2 day 1";
     cin >> monthlytemps[1][0];
     cout << "Enter the temp for week 2 day 2";
     cin >> monthlytemps[1][1];
     cout << "Enter the temp for week 2 day 3";
     cin >> monthlytemps[1][2];
     cout << "Enter the temp for week 2 day 4";
     cin >> monthlytemps[1][3];
     cout << "Enter the temp for week 2 day 5";
     cin >> monthlytemps[1][4];
     cout << "Enter the temp for week 2 day 6";
     cin >> monthlytemps[1][5];
     cout << "Enter the temp for week 2 day 7";
     cin >> monthlytemps[1][6];
     cout << "Enter the temp for week 3 day 1";
     cin >> monthlytemps[3][0];
     cout << "Enter the temp for week 3 day 2";
     cin >> monthlytemps[3][1];
     cout << "Enter the temp for week 3 day 3";
     cin >> monthlytemps[3][2];
     cout << "Enter the temp for week 3 day 4";
     cin >> monthlytemps[3][3];
     cout << "Enter the temp for week 3 day 5";
     cin >> monthlytemps[3][4];
     cout << "Enter the temp for week 3 day 6";
     cin >> monthlytemps[3][5];
     cout << "Enter the temp for week 3 day 7";
     cin >> monthlytemps[3][6];
     
     cout << "Enter the temp for week 4 day 1";
     cin >> monthlytemps[4][0];
     cout << "Enter the temp for week 4 day 2";
     cin >> monthlytemps[4][1];
     cout << "Enter the temp for week 4 day 3";
     cin >> monthlytemps[4][2];
     cout << "Enter the temp for week 4 day 4";
     cin >> monthlytemps[4][3];
     cout << "Enter the temp for week 4 day 5";
     cin >> monthlytemps[4][4];
     cout << "Enter the temp for week 4 day 6";
     cin >> monthlytemps[4][5];
     cout << "Enter the temp for week 4 day 7";
     cin >> monthlytemps[4][6];
     return 0;
}








4.4.multi dimension array
4.4.1.Declare a two-dimension array
4.4.2.Initialize a two-dimension array
4.4.3.Creating A Multidimensional Array
4.4.4.Initializing multidimensional arrays
4.4.5.Search a two-dimension array
4.4.6.Use nested for loop to display the two dimesional array
4.4.7.Using pointer notation with a multidimensional array
4.4.8.Fill a two dimensional integer array element by element
4.4.9.how to define, pass, and walk through the different dimensions of an array