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 program

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 = 224
v1 = 224
136
137
138
139
140
141
142
143
?
?
?
?
res = 0
176
177
178
179
n = 2

dotprod()

128
129
130
131
132
133
134
135
v2 = 224
v1 = 216
136
137
138
139
140
141
142
143
?
?
?
?
res = 0
176
177
178
179
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
176
177
178
179
n = 2

dotprod()

128
129
130
131
132
133
134
135
v2 = 216
v1 = 216
136
137
138
139
140
141
142
143
?
?
?
?
res = 0
176
177
178
179
n = 2

dotprod()

128
129
130
131
132
133
134
135
v2 = 232
v1 = 216
136
137
138
139
140
141
142
143
?
?
?
?
res = 0
176
177
178
179
n = 2

dotprod()

128
129
130
131
132
133
134
135
v2 = 232
v1 = 224
136
137
138
139
140
141
142
143
?
?
?
?
res = 0
176
177
178
179
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()

208
209
210
211
212
213
214
215
j = -538248967
k = -46473827
216
217
218
219
220
221
222
223
vector[0][0] = 1.5
vector[0][1] = 3.9
224
225
226
227
228
229
230
231
vector[1][0] = 4.7
vector[1][1] = 7.2
232
233
234
235
236
237
238
239
vector[2][0] = 2.1
vector[2][1] = 5.13
240
241
242
243
244
245
246
247
dot[0][0] = 2.5462e-08
dot[0][1] = 3.97963e+33
248
249
250
251
252
253
254
255
dot[0][2] = 1.65772e+27
dot[1][0] = 1.02965e-17
256
257
258
259
260
261
262
263
dot[1][1] = 2.38715e+28
dot[1][2] = -1.58221e+25
264
265
266
267
268
269
270
271
dot[2][0] = 7.18707e-08
dot[2][1] = -1.90287e+17
272
273
274
275
dot[2][2] = -4.49525e+33

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

Show Advanced options

.
                                                                                                                                                                                                                                                                       

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