Hi everyone,

I'm trying to write a program that involves passing out some variables to a sub-routine to calculate some other variables. Here is the code:

Code:

#include <stdio.h>
#include <math.h>
int main (int argc, const char * argv[]) {
double T;
double r[7][4], k[7][4], A[7] = { 1, 2, 3, 4, 5, 6, 7}, Ea[7] = { 10, 20, 30, 40, 50, 60, 70}, K[2][4], Ad[2], Ead[2];
void rateConstants(double k[7][4], double A[7], double Ea[7], double T);
T = 443.15;
rateConstants(k, A, Ea, T);
printf("\n %lf \n", k[1]);
return 0;
}
void rateConstants(double k[7][4], double A[7], double Ea[7], double T)
{
int i, j;
j = 0;
for (i=0; i<6; i++)
{
k[i][j] = A[i]*exp(-Ea[i]/(8.31*T));
printf("\n %lf", k[i][j]);
}
}

As you can see, the subroutine prints out each value of k[i][j] that it calculates, then I have the main routine print out one of the k values to check if it's stored.However, the readout I actually get is:

0.997288

1.989167

2.975660

3.956787

4.932572

5.903034

-1.997117

logout

It doesn't matter what k value I choose, they all come out as -1.997117. Can anyone see what I'm doing wrong? I wrote a similar program for a much simpler case (as a test), and it all seemed to work.

I should warn you that I am not a brilliant programmer, so you may have to explain things to me quite explicitly.

Thanks in advance!