C++ Array Output two dimensional array

Description

C++ Array Output two dimensional array

#include <iostream>
using namespace std;
#include <iomanip.h>
void main()/*ww  w  .ja  v a2s  . co  m*/
{
   float disks[2][4];  // Table of disk prices.
   int row, col;       // Subscript variables.
   disks[0][0] = 2.39;      // Row 1, column 1
   disks[0][1] = 2.75;      // Row 1, column 2
   disks[0][2] = 3.29;      // Row 1, column 3
   disks[0][3] = 3.59;      // Row 1, column 4
   disks[1][0] = 1.75;      // Row 2, column 1
   disks[1][1] = 2.19;      // Row 2, column 2
   disks[1][2] = 2.69;      // Row 2, column 3
   disks[1][3] = 2.95;      // Row 2, column 4
   // Print the prices.
   for (row=0; row<2; row++)
   {
      for (col=0; col<4; col++)
      {
         cout << "$" << setprecision(2) << disks[row][col] << "\n"; }
      }
      return;
}



PreviousNext

Related