For a college homework assignment, I was asked to
write an array called "alpha" composed of 50 components type double.
The first 25 have to be the square of the index, while the last 25 have to be 3 times the index, and it was to be a 2-D array with 10 numbers a line. However, my output seems to be weird.
using namespace std;
You should also use the for loops to initialise the array, not hard code the values like that. Use the program to do work for you, not you do all the work yourself. This is the whole idea of programming.
Wow, thanks for the insanely fast reply. I had taken your advice on letting the program do the work, and I've come up with an idea. However we'll executing it, intelisense gives me the error "must be integral or enum type" where the "i" values are.. Keep in mind this isn't the whole program, I was just testing out a few values.
This works like this: when i=0 j=0 is 0,0 index, that is 1*1, result 1. Next i=0 j=1 index 0,1 that is 2*2, result 4 and so on. When j hits 10, the first for loop executes again, makes i=1 and second for loop executes utill j=10 again. Continues untill i equals 5.
I ended up finishing the assignment, thank you all for those who replied.
Although it probably wasn't the most efficent programming man has ever seen, it got the job done. I plan on meeting my instructor to better understand for loops later. Thanks again everyone for helping me. This forum is amazing.