Answer to Question #159666 in C++ for zain ul abdeen

Question #159666

Write a program that takes values of a 2D array of 3x3 size and prints the array in matrix form. Like:..

 An array of 3x3 size :

4

6

8

12

11

12

10

12

14


1
Expert's answer
2021-01-30T10:32:59-0500

// the preprocessing directives

#include<iostream>   // cin, cout

#include <iomanip>   // setw(n)

using namespace std;

int main( )

  // declare and initialize variables

  int array[3][3];

  int i, j;      // counters in column and row


  // takes values of a 2D array of 3x3 size

  cout<<"An array of 3x3 size:"<<endl<<endl;

  for(i=0; i<3; i++) {

       for(j=0; j<3; j++) {

           cin>>array[i][j];

           cout<<endl;

       }

     }

  // Prints the array in matrix form   

     cout<<endl<<"An array of 3x3 size:"<<endl;

     for(i=0;i<3;i++) {

       for(j=0;j<3;j++) {

           cout<< setw(4)<<array[i][j];

       }

       cout<<endl;

     }

     return 0;

}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog