Declaring and Processing Two-Dimensional Arrays, Multiply each element by 10 and display it - C++ Data Type

C++ examples for Data Type:Array

Description

Declaring and Processing Two-Dimensional Arrays, Multiply each element by 10 and display it

Demo Code

#include <iostream>
#include <iomanip>
using namespace std;
int main()/*from  w w w. ja  v  a2s.  c om*/
{
   const int NUMROWS = 3;
   const int NUMCOLS = 4;
   int i, j;
   int val[NUMROWS][NUMCOLS] = {8,6,9,52, 3,5,2,6, 4,2,2,1};
   cout << "\nDisplay of multiplied elements";
   for (i = 0; i < NUMROWS; i++)
   {
      cout << endl;   // start each row on a new line
      for (j = 0; j < NUMCOLS; j++)
      {
         val[i][j] = val[i][j] * 10;
         cout << setw(5) << val[i][j];
      }
   }
   cout << endl;
   return 0;
}

Result


Related Tutorials