Skip to content
EMPS intranet

Back to top

Note

  • This code has been compiled to show the internal calculations of the addresses of array elements like this: 824.
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...
// Return the scalar (dot) product of two vectors
float dotprod(float v1[],float v2[],int n){
  ...
» float res=0; » for ( int i=0;i<n; ++i) res+=v1i*v2i; » return res;
} #define VECLEN 2 #define NVECS 3 int main(){
  ...
» float dot[NVECS][NVECS], vector[NVECS][VECLEN]= {1.5,3.9,4.7,7.2,2.1,5.13,}; » int j, k; » for (j=0; j<NVECS; ++j) { » for (k=j; k<NVECS; ++k) dot[j]k=dotprod(vectorj, vectork, VECLEN); } » return 1;
}
Memory

dotprod()

128
129
130
131
132
133
134
135
v2 = 240
v1 = 232
136
137
138
139
140
141
142
143
?
?
?
?
res = 0
192
193
194
195
n = 2

dotprod()

128
129
130
131
132
133
134
135
v2 = 240
v1 = 240
136
137
138
139
140
141
142
143
?
?
?
?
res = 0
192
193
194
195
n = 2

dotprod()

128
129
130
131
132
133
134
135
v2 = 248
v1 = 240
136
137
138
139
140
141
142
143
?
?
?
?
res = 0
192
193
194
195
n = 2

dotprod()

128
129
130
131
132
133
134
135
v2 = 248
v1 = 232
136
137
138
139
140
141
142
143
?
?
?
?
res = 0
192
193
194
195
n = 2

dotprod()

128
129
130
131
132
133
134
135
v2 = 232
v1 = 232
136
137
138
139
140
141
142
143
?
?
?
?
res = 0
192
193
194
195
n = 2

dotprod()

128
129
130
131
132
133
134
135
v2 = 248
v1 = 248
136
137
138
139
140
141
142
143
?
?
?
?
res = 0
192
193
194
195
n = 2

dotprod(): for()

144
145
146
147
i = 0

dotprod(): for()

144
145
146
147
i = 0

dotprod(): for()

144
145
146
147
i = 0

dotprod(): for()

144
145
146
147
i = 0

dotprod(): for()

144
145
146
147
i = 0

dotprod(): for()

144
145
146
147
i = 0

main()

224
225
226
227
228
229
230
231
j = -145110183
k = -143765504
232
233
234
235
236
237
238
239
vector[0][0] = 1.5
vector[0][1] = 3.9
240
241
242
243
244
245
246
247
vector[1][0] = 4.7
vector[1][1] = 7.2
248
249
250
251
252
253
254
255
vector[2][0] = 2.1
vector[2][1] = 5.13
256
257
258
259
260
261
262
263
dot[0][0] = 3.99889e-34
dot[0][1] = 1.4013e-45
264
265
266
267
268
269
270
271
dot[0][2] = -nan
dot[1][0] = -4.29842e+33
272
273
274
275
276
277
278
279
dot[1][1] = 1.4013e-45
dot[1][2] = 2.8026e-43
280
281
282
283
284
285
286
287
dot[2][0] = -4.40281e+33
dot[2][1] = -4.83355e+33
288
289
290
291
dot[2][2] = 1.4013e-45

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

Show Advanced options

.
                                                                                                                                                                                                                                                                       

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