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...
// Return the square root of the argument or minus one if it is negative
double sqrtOrMinusOne(double x){
  ...
» if (x>=0) return sqrt(x); » printf("Warning: %g is negative\n", x); » return -1;
} int main(){
  ...
» double a, b; » a=sqrtOrMinusOne(9.0); » b=sqrtOrMinusOne(-3); » printf("x: %g y: %g\n", a, b); » return -1;
}

Data

sqrtOrMinusOne()

x (double)
128
9

sqrtOrMinusOne()

x (double)
128
-3

main()

a (double)   b (double)
192   200
-9.21503234e+266
  
4.93593587e-270

Memory

sqrtOrMinusOne()

128
129
130
131
132
133
134
135
x = 9

sqrtOrMinusOne()

128
129
130
131
132
133
134
135
x = -3

main()

192
193
194
195
196
197
198
199
a = -9.21503234e+266
200
201
202
203
204
205
206
207
b = 4.93593587e-270

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

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

Warning: -3 is negative
x: 3 y: -1
                                                                                                                                                                                                                                                                       

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