Hello, i need some help with C++...I'm attempting to make an 4x4 array. The user inputs the array
"Line 1: " // the the user inputs his 4 numbers for line 1 and so on....
the program then adds the array across on all 4 lines, and twice diagonally. I can only use

using namespace std;

int main (){
//using only types int and double

I want it to be stupid simple, using for loops, and make it as simple as possible. I realize that you must
int i, j;

for(i=0; i<4; i++){
cout << "enter line 1" << i << endl;
cin >> i; // not sure if this is
for(j=0; j<4; j++) // right but I know
// the for's are right
// or at least on trak

so i know the fors are getting there, but i have no clue how a user can input integers in an array, and i think i know how to add them

[0][0]+[0][1]+[0][2]+[0][3]= result

am i even close? can you give me some code please!!!


First, read stickies and readmes scattered liberally around the forum. In particular, you seem to have missed the readme on CODE tags.

Grab several variables from the standard input using multiple inputs. The user can enter them all on one line (whitespace-separated), or they can enter each one on a separate line (newline-separated).

cin >> array[i][0] >> array[i][1]
    >> array[i][2] >> array[i][3];

Of course, you can also use a loop to make it a little bit simpler:

for (int j = 0; j < 4; j++)
   cin >> array[i][j];

So your entire input loop would look something like this:

for (int i=0; i < 4; i++)
   for (int j = 0; j < 4; j++)
      cin >> array[i][j];