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)

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] = -4.94384e+33
152
153
154
155
156
157
158
159
ellie.centre[1] = 1.4013e-45
ellie.axes[0] = -4.51316e+33
160
161
162
163
164
165
166
167
ellie.axes[1] = 3.99955e-34
ellie.orientation = 3.99945973e-34
168
169
170
171
ellie.area = 1.40129846e-45

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

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