No errors but exe refuses to run. What gives?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#include <stdio.h>
#include <iostream>
#include <algorithm>
#define N 10
double matrix_det ( double **in_matrix, int n )
{
  int i, j, k;
  double **matrix;
  double det = 1;
   
  matrix = new double *[n];
   
  for (i=0;i<n;i++)
    matrix[i] = new double[n];
   
  for (i=0;i<n;i++) {
    for (j=0;j<n;j++)
      matrix[i][j] = in_matrix[i][j];
  }
   
  for (k=0;k<n;k++) {
    if (matrix[k][k] == 0 ) {
      bool ok = false;
       
      for (j=k;j<n;j++) {
        if (matrix[j][k] != 0 )
          ok = true;
      }
       
      if ( !ok )
        return 0;
       
      for (i=k;i<n;i++)
        std::swap ( matrix[i][j], matrix[i][k] );
       
      det = -det;
    }
     
    det *= matrix[k][k];
 
    if (k+1<n) {
      for (i=k+1;i<n;i++) {
        for (j=k+1;j<n;j++)
          matrix[i][j] = matrix[i][j] - matrix[i][k] * 
          matrix[k][j] / matrix[k][k];
      }
    }
  }
 
  for (i=0;i<n;i++)
    delete [] matrix[i];
 
  delete [] matrix;
   
  return det;
}

int main(void)
{
	int i, j;
	double **arr, **arr1, **arr2, **arr3, **arr4, **arr5, **arr6, **arr7, **arr8, **arr9, **arr10;
	double f[N], c[11], d[N], e[N];
    arr = new double *[N];
	arr1 = new double *[N];
	arr2 = new double *[N];
	arr3 = new double *[N];
	arr4 = new double *[N];
	arr5 = new double *[N];
	arr6 = new double *[N];
	arr7 = new double *[N];
	arr8 = new double *[N];
	arr9 = new double *[N];
	arr10 = new double *[N];
   
	for (i=0;i<N;i++)
	{	
		arr[i] = new double[N];
		arr1[i] = new double[N];
		arr2[i] = new double[N];
		arr3[i] = new double[N];
		arr4[i] = new double[N];
		arr5[i] = new double[N];
		arr6[i] = new double[N];
		arr7[i] = new double[N];
		arr8[i] = new double[N];
		arr9[i] = new double[N];
		arr10[i] = new double[N];
	}

	for (i=0;i<N;i++)
	{	for(j=0;j<N;j++)
		{	
			arr[i][j] = (2*i*j)/((i+j)*((i+j)*(i+j)-1)) - 32/((i+j+1)*(i+j+2)*(i+j+3));
			arr1[i][j] = arr[i][j];
			arr2[i][j] = arr[i][j];
			arr3[i][j] = arr[i][j];
			arr4[i][j] = arr[i][j];
			arr5[i][j] = arr[i][j];
			arr6[i][j] = arr[i][j];
			arr7[i][j] = arr[i][j];
			arr8[i][j] = arr[i][j];
			arr9[i][j] = arr[i][j];
			arr10[i][j] = arr[i][j];
		}
	}

	for (i=0;i<N;i++)
	{	
		f[i] = -1/((3+i)*(4+i));
	}

	for (i=0;i<N;i++)
	{	arr1[i][0] = f[i];
	}

	for (i=0;i<N;i++)
	{	arr2[i][1] = f[i];
	}

	for (i=0;i<N;i++)
	{	arr3[i][2] = f[i];
	}

	for (i=0;i<N;i++)
	{	arr4[i][3] = f[i];
	}

	for (i=0;i<N;i++)
	{	arr5[i][4] = f[i];
	}

	for (i=0;i<N;i++)
	{	arr6[i][5] = f[i];
	}

	for (i=0;i<N;i++)
	{	arr7[i][6] = f[i];
	}

	for (i=0;i<N;i++)
	{	arr8[i][7] = f[i];
	}
	
	for (i=0;i<N;i++)
	{	arr9[i][8] = f[i];
	}

	for (i=0;i<N;i++)
	{	arr10[i][9] = f[i];
	}

	c[0] = matrix_det(arr,N);
	c[1] = matrix_det(arr1,N);
	c[2] = matrix_det(arr2,N);
	c[3] = matrix_det(arr3,N);
	c[4] = matrix_det(arr4,N);
	c[5] = matrix_det(arr5,N);
	c[6] = matrix_det(arr6,N);
	c[7] = matrix_det(arr7,N);
	c[8] = matrix_det(arr8,N);
	c[9] = matrix_det(arr9,N);
	c[10] = matrix_det(arr10,N);

	for (i=0;i<N;i++)
	{
		int g = i+1;
		d[i] = c[g] / c[i];
	}
	
	e[0] = d[0];

	for (i=1;i<N;i++)
	{
		int h = i-1;
		e[i] = d[i] - d[h];
	}

	printf("The ten parameter Rayleigh-Ritz solution is given by: \n");
	printf("u = %fx + %fx^2 + %fx^3 + %fx^4 + %fx^5 + %fx^6 + %fx^7 + %fx^8 + %fx^9 + %fx^10", e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], e[8], e[9]);
	return 0;

}


Hi all, there's no errors during compiling but it refuses to execute. Can anyone enlighten me? For your information, I'm using Visual C++ 6.0.
You are dividing by zero on line 93.
Hi when i compile it in my Visual C++ 2010 express there was no errors
But when I run it, it shows the following error

First-chance exception at 0x01001a80 in example_2.exe: 0xC0000094: Integer division by zero.
Unhandled exception at 0x01001a80 in example_2.exe: 0xC0000094: Integer division by zero.



Line number was 93
Ah....thanks for correcting my mistake!
Topic archived. No new replies allowed.