Skip to content
EMPS intranet

Back to top

Try stepping through the code


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

The ellipse el in print_area() is a copy of ellie in main()

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 PI 3.14159265358979 typedef struct ellipse { float centre[2]; float axes[2]; float orientation; }Ellipse;
void print_area(Ellipse el){ » float area; » area=PI*el.axes[0]*el.axes[1]; » printf("The area is %f\n", area); » el.centre0=123.456;// Move the ellipse » el.centre1=-78.9; }
...
int main(){ » Ellipse ellie; » printf("Centre? (x,y)\n"); » scanf("%f %f", &ellie.centre[0], &ellie.centre[1]); // NB: in a real program we should check // the axes are actually > 0 » printf("Length of axes ( > 0 )?\n"); » scanf("%f %f", &ellie.axes[0], &ellie.axes[1]); » printf("Orientation to the vertical?\n"); » scanf("%f", &ellie.orientation); » print_area(ellie); » return 0; }
...
Memory

print_area()

128
129
130
131
132
133
134
135
area = -nan
?
?
?
?
152
153
154
155
156
157
158
159
el.centre[0] = 7.2
el.centre[1] = 4.5
160
161
162
163
164
165
166
167
el.axes[0] = 1.2
el.axes[1] = 4.3
168
169
170
171
el.orientation = 1.70000005

main()

192
193
194
195
196
197
198
199
ellie.centre[0] = -4.49525e+33
ellie.centre[1] = 5.05323e-20
200
201
202
203
204
205
206
207
ellie.axes[0] = 1.15682e-11
ellie.axes[1] = 2.06952e+24
208
209
210
211
ellie.orientation = -2.50234124e-25

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

Show Advanced options

.

Input was:

7.2 4.5 1.2  4.3 1.7

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

Output

Centre? (x,y)
Length of axes ( > 0 )?
Orientation to the vertical?
The area is 16.210619
                                                                                                                                                                                                                                                                       

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