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...
/* * Given a cheesecake of known mass and calories * calculate various calorific value. * All masses are in grammes. */
int main(){
  ...
//? Input data » double mass_tot=550; » double cals_tot=399*6; » double cals_per_lb=3500; » double grammes=500; //? Calculated quantities » double cals_100g=cals_tot*100/mass_tot; » double cake_lb_fat=cals_tot/cals_per_lb; » double cakes_stone=14*cals_per_lb/cals_tot; » printf("Calories per 100g:\t%g\n", cals_100g); » printf("Calories per 1/4 cheescake:\t%g\n", cals_tot/4.0); » printf("Fraction of cheesecake for %g Calories:\t%g\n", grammes, grammes*cals_100g/100.0); » printf("Pounds of fat added per cheescake: %g\n", cake_lb_fat); » printf("Cheesecakes to put on one stone: %g\n", cakes_stone); » return 0;
}
Memory

main()

128
129
130
131
132
133
134
135
mass_tot = 550
136
137
138
139
140
141
142
143
cals_tot = 2394
144
145
146
147
148
149
150
151
cals_per_lb = 3500
152
153
154
155
156
157
158
159
grammes = 500
160
161
162
163
164
165
166
167
cals_100g = 435.272727
168
169
170
171
172
173
174
175
cake_lb_fat = 0.684
176
177
178
179
180
181
182
183
cakes_stone = 20.4678363

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

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

Calories per 100g:	435.273
Calories per 1/4 cheescake:	598.5
Fraction of cheesecake for 500 Calories:	2176.36
Pounds of fat added per cheescake: 0.684
Cheesecakes to put on one stone: 20.4678
                                                                                                                                                                                                                                                                       

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