I have been sitting scratching my head on why I am getting the wrong values outputted for aplpha. I changed the variable name from "a" to "alpha" thinking it was a variable name issue. Someone please help me with this as it is due tommorow. Could this be an issue with my compiler? I am using devC++
Any help is appreiated!
This program calculates a full 5x3 array using existing values.
A=
1 2 3 4 5
1 2 22 24 26 28
2 12 14 16 18 90
3 22 24 26 28 98
26
--------------------------------
Process exited after 0.07828 seconds with return value 0
Press any key to continue . . .
If you declare an array as alpha[4][2];
Its valid indices range from alpha[0][0] to alpha[3][1]. alpha[4][2] as an index is not a valid location.
In other words, in your code,
line 18: bad
line 23-28: all bad
(Likewise, there are the same problems when you attempt to print out the invalid indices.)
alpha[5][1]
This is even further wrong, there is no alpha[5][...], let alone alpha[4][...].
Always remember: It's never the compiler (until it is).
Also remember that arrays are indexed from 0 up to their size - 1. You seem to want a size of 5 by 3, not 4 by 2 for alpha. The others are off by one, too.
But I still do not understand...if I want to assign: alpha[1][2]
...a value, why does the equal operator not work? From a computer logic perspective?
I am stuck on the initilization part, I just do not know why the above will not work!