Skip to content
EMPS intranet

Back to top
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)

The pointer el inside calculate_area() points to ellie inside main() so el->member refers to ellie.member.

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; float area; }Ellipse;
void calculate_area(Ellipse *el){ » el->area=PI*el->axes[0]*el->axes[1]; }
...
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); » calculate_area(&ellie); » return 0; }
...
Memory

calculate_area()

128
129
130
131
el = 148

main()

148
149
150
151
ellie.centre[0] = -2.68816e+17
152
153
154
155
156
157
158
159
ellie.centre[1] = -4.49525e+33
ellie.axes[0] = 5.05323e-20
160
161
162
163
164
165
166
167
ellie.axes[1] = 9.04191e-12
ellie.orientation = 1.96563216e+24
168
169
170
171
ellie.area = -2.64774408e-25

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

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?
                                                                                                                                                                                                                                                                       

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