I am taking a beginning programming class, and we need to make a program where the user enters in a 4x4 square of random numbers. Then the program needs tell the user if the square is magic or not meaning that all the rows and columns and even the two diagonals are equal. We are not supposed to use arrays. I am totally lost and not even sure where to start. I can use all the help I can get. Thanks!
In fact you need not to keep entered values. All what you need is some special sums of entered values. So you should define one variable which will keep the sum of elements of the first row. And then you will compare it with calculated sums of other rows, columns and dioganals.
So in total there will be 5 variables: one - for the sum of the first row, one - for the sum of other rows, one - for sum of any column, one - for sum of the first diagonal, and one - for the second diagonal.
Ok I see what you are say. so I would set it up like this
int sum1 = 0;
int sum2 = 0;
int sum3 = 0;
int sum4 = 0;
int sum5 = 0;
Or are you thinking of something different?
Also Im sorry but this really is my first time ever programming in C++. How would i set up the equations to compare if the values are equal or not equal?
Ok so I talk to my professor and he said that we cannot use loops because this is a basic class. I am still not sure where to start. Any help or ideas would be appreciated! thank you!