Skip to content
EMPS intranet

Back to top
Hi!   Hi!           Start main()

Try stepping through the code


  Value and type of last evaluated expression: Address of array element: Address of array elementx:  (none)

Your browser does not support the canvas element which will make some the features unavailable.

If you are using Internet Explorer within the University of Exeter try going to the Settings menu (probably the gear shape at the top right of this page), selecting "Compatibility View settings", unchecking "Display intranet sites in Compatibility View" and reloading this page.

Code

 Header...
#define NX 3 #define NY 2 void normalise (float p[],int n);
int main(){
  ...
» int x, y; » float coeffs[NX][NY]={{1,2},{3,4},{5,6}}; // Normalise the indivdual vectors » for (x=0; x<NX; ++x) normalise(coeffs[x], NY); » printf("The matrix is:\n"); » for (x=0; x<NX; ++x) for (y=0; y<NY; ++y) printf("coeffs[%d][%d] is %g\n", x, y, coeffs[x]y); » return 0;
} // Normalise a vector (an array) of length n void normalise(float p[],int n){
  ...
» float norm=0; » int i; » for (i=0; i<n; ++i) norm+=pi*pi; » norm=sqrt(norm); » if (norm>0) { » for (i=0; i<n; ++i) pi/=norm; }
}
Memory

normalise()

132
133
134
135
p = 252
136
137
138
139
140
141
142
143
?
?
?
?
norm = 0
144
145
146
147
148
149
150
151
i = -3767832
?
?
?
?
184
185
186
187
188
189
190
191
?
?
?
?
n = 2

normalise()

132
133
134
135
p = 236
136
137
138
139
140
141
142
143
?
?
?
?
norm = 0
144
145
146
147
148
149
150
151
i = -3767832
?
?
?
?
184
185
186
187
188
189
190
191
?
?
?
?
n = 2

normalise()

132
133
134
135
p = 244
136
137
138
139
140
141
142
143
?
?
?
?
norm = 0
144
145
146
147
148
149
150
151
i = -3767832
?
?
?
?
184
185
186
187
188
189
190
191
?
?
?
?
n = 2

main()

228
229
230
231
x = 1
232
233
234
235
236
237
238
239
y = -3767804
coeffs[0][0] = 1
240
241
242
243
244
245
246
247
coeffs[0][1] = 2
coeffs[1][0] = 3
248
249
250
251
252
253
254
255
coeffs[1][1] = 4
coeffs[2][0] = 5
256
257
258
259
coeffs[2][1] = 6

NB: the actual memory address of each variable is the
address shown plus 4291199176 (0xFFC680C8).

Show Advanced options

.
Show output (Before looking at the output, work out what you think it put should be and see if you are right.)

Output

The matrix is:
coeffs[0][0] is 0.447214
coeffs[0][1] is 0.894427
coeffs[1][0] is 0.6
coeffs[1][1] is 0.8
coeffs[2][0] is 0.640184
coeffs[2][1] is 0.768221
                                                                                                                                                                                                                                                                       

Validate   Link-check © Copyright & disclaimer Share
Back to top