Answer to Question #337929 in C++ for herry

Question #337929

Write a function arraylist which receives an array of integer values. The list of elements are

the following:

20, 40, 60, 80

50, 90, 70, 10

30, 100, 200, 300


1
Expert's answer
2022-05-06T15:36:37-0400
#include <iostream>
using namespace std;
int main() {
    const int line = 3;
    const int col = 4;
    int array[line][col] = {};
    int i,j;
    cout << "Enter twelve numbers:\n";

        
    for( i=0; i<line; ++i)   {
        for( j=0; j<col; ++j)  {
            cin >> array[i][j];
            if(!cin)   {
                cout << "Bad input\n";
                return 1;
            }
        }
    }
    
    for( i=0; i<line; ++i)   {
        for( j=0; j<col; ++j)  {
            cout<<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
APPROVED BY CLIENTS