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...
//
// Accept a number in the range 1-12 and return the name of
// the month.
//
const char * month_name(int month){ ...
» const char *m, *months[12]={"January","February","March","April","May","June","July","August","September","October","November","December"};
» if (month>0&&month<=12)
m=months(month-1);
else
m=NULL;
» return m;
}
int main(){ ...
» int m;
» const char *mname;
» for (m=1; m<=12; ++m) {
»mname=month_name(m);
»printf("Month %d is called %s\n", m, mname);
}
» return 0;
}
Memory
Fixed strings
132
133
134
135
'M'
'o'
'n'
't'
136
137
138
139
140
141
142
143
'h'
' '
'%'
'd'
' '
'i'
's'
' '
144
145
146
147
148
149
150
151
'c'
'a'
'l'
'l'
'e'
'd'
' '
'%'
152
153
154
's'
'\n'
'\0'
month_name()
288
289
290
291
292
293
294
295
m = 360
months[0] =
296
297
298
299
300
301
302
303
months[1] =
months[2] =
304
305
306
307
308
309
310
311
months[3] =
months[4] =
312
313
314
315
316
317
318
319
months[5] =
months[6] =
320
321
322
323
324
325
326
327
months[7] =
months[8] =
328
329
330
331
332
333
334
335
months[9] =
months[10] =
336
337
338
339
340
341
342
343
months[11] =
?
?
?
?
376
377
378
379
month = 9
month_name()
288
289
290
291
292
293
294
295
m = 360
months[0] =
296
297
298
299
300
301
302
303
months[1] =
months[2] =
304
305
306
307
308
309
310
311
months[3] =
months[4] =
312
313
314
315
316
317
318
319
months[5] =
months[6] =
320
321
322
323
324
325
326
327
months[7] =
months[8] =
328
329
330
331
332
333
334
335
months[9] =
months[10] =
336
337
338
339
340
341
342
343
months[11] =
?
?
?
?
376
377
378
379
month = 10
month_name()
288
289
290
291
292
293
294
295
m = 360
months[0] =
296
297
298
299
300
301
302
303
months[1] =
months[2] =
304
305
306
307
308
309
310
311
months[3] =
months[4] =
312
313
314
315
316
317
318
319
months[5] =
months[6] =
320
321
322
323
324
325
326
327
months[7] =
months[8] =
328
329
330
331
332
333
334
335
months[9] =
months[10] =
336
337
338
339
340
341
342
343
months[11] =
?
?
?
?
376
377
378
379
month = 11
month_name()
288
289
290
291
292
293
294
295
m = 360
months[0] =
296
297
298
299
300
301
302
303
months[1] =
months[2] =
304
305
306
307
308
309
310
311
months[3] =
months[4] =
312
313
314
315
316
317
318
319
months[5] =
months[6] =
320
321
322
323
324
325
326
327
months[7] =
months[8] =
328
329
330
331
332
333
334
335
months[9] =
months[10] =
336
337
338
339
340
341
342
343
months[11] =
?
?
?
?
376
377
378
379
month = 8
month_name()
288
289
290
291
292
293
294
295
m = 360
months[0] =
296
297
298
299
300
301
302
303
months[1] =
months[2] =
304
305
306
307
308
309
310
311
months[3] =
months[4] =
312
313
314
315
316
317
318
319
months[5] =
months[6] =
320
321
322
323
324
325
326
327
months[7] =
months[8] =
328
329
330
331
332
333
334
335
months[9] =
months[10] =
336
337
338
339
340
341
342
343
months[11] =
?
?
?
?
376
377
378
379
month = 12
month_name()
288
289
290
291
292
293
294
295
m = 360
months[0] =
296
297
298
299
300
301
302
303
months[1] =
months[2] =
304
305
306
307
308
309
310
311
months[3] =
months[4] =
312
313
314
315
316
317
318
319
months[5] =
months[6] =
320
321
322
323
324
325
326
327
months[7] =
months[8] =
328
329
330
331
332
333
334
335
months[9] =
months[10] =
336
337
338
339
340
341
342
343
months[11] =
?
?
?
?
376
377
378
379
month = 2
month_name()
288
289
290
291
292
293
294
295
m = 360
months[0] =
296
297
298
299
300
301
302
303
months[1] =
months[2] =
304
305
306
307
308
309
310
311
months[3] =
months[4] =
312
313
314
315
316
317
318
319
months[5] =
months[6] =
320
321
322
323
324
325
326
327
months[7] =
months[8] =
328
329
330
331
332
333
334
335
months[9] =
months[10] =
336
337
338
339
340
341
342
343
months[11] =
?
?
?
?
376
377
378
379
month = 5
month_name()
288
289
290
291
292
293
294
295
m = 360
months[0] =
296
297
298
299
300
301
302
303
months[1] =
months[2] =
304
305
306
307
308
309
310
311
months[3] =
months[4] =
312
313
314
315
316
317
318
319
months[5] =
months[6] =
320
321
322
323
324
325
326
327
months[7] =
months[8] =
328
329
330
331
332
333
334
335
months[9] =
months[10] =
336
337
338
339
340
341
342
343
months[11] =
?
?
?
?
376
377
378
379
month = 7
month_name()
288
289
290
291
292
293
294
295
m = 360
months[0] =
296
297
298
299
300
301
302
303
months[1] =
months[2] =
304
305
306
307
308
309
310
311
months[3] =
months[4] =
312
313
314
315
316
317
318
319
months[5] =
months[6] =
320
321
322
323
324
325
326
327
months[7] =
months[8] =
328
329
330
331
332
333
334
335
months[9] =
months[10] =
336
337
338
339
340
341
342
343
months[11] =
?
?
?
?
376
377
378
379
month = 1
month_name()
288
289
290
291
292
293
294
295
m = 360
months[0] =
296
297
298
299
300
301
302
303
months[1] =
months[2] =
304
305
306
307
308
309
310
311
months[3] =
months[4] =
312
313
314
315
316
317
318
319
months[5] =
months[6] =
320
321
322
323
324
325
326
327
months[7] =
months[8] =
328
329
330
331
332
333
334
335
months[9] =
months[10] =
336
337
338
339
340
341
342
343
months[11] =
?
?
?
?
376
377
378
379
month = 3
month_name()
288
289
290
291
292
293
294
295
m = 360
months[0] =
296
297
298
299
300
301
302
303
months[1] =
months[2] =
304
305
306
307
308
309
310
311
months[3] =
months[4] =
312
313
314
315
316
317
318
319
months[5] =
months[6] =
320
321
322
323
324
325
326
327
months[7] =
months[8] =
328
329
330
331
332
333
334
335
months[9] =
months[10] =
336
337
338
339
340
341
342
343
months[11] =
?
?
?
?
376
377
378
379
month = 4
month_name()
288
289
290
291
292
293
294
295
m = 360
months[0] =
296
297
298
299
300
301
302
303
months[1] =
months[2] =
304
305
306
307
308
309
310
311
months[3] =
months[4] =
312
313
314
315
316
317
318
319
months[5] =
months[6] =
320
321
322
323
324
325
326
327
months[7] =
months[8] =
328
329
330
331
332
333
334
335
months[9] =
months[10] =
336
337
338
339
340
341
342
343
months[11] =
?
?
?
?
376
377
378
379
month = 6
main()
412
413
414
415
m = 134537258
416
417
418
419
mname = -4287714343
NB: the actual memory address of each variable is
the address shown plus 4287714344 (0xFF915428).
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
Month 1 is called January
Month 2 is called February
Month 3 is called March
Month 4 is called April
Month 5 is called May
Month 6 is called June
Month 7 is called July
Month 8 is called August
Month 9 is called September
Month 10 is called October
Month 11 is called November
Month 12 is called December