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...
int main(){
  ...
» double x; » x=sqrt(2.0); » if (x*x==2.0) // Wrong! printf("x*x is exactly 2\n"); else printf("x*x - 2 is %g\n", x*x-2.0); » if (fabs(x*x-2.0)<1e-6) // Right printf("Close enough!\n"); // Now let's see what happens when we use abs() by mistake » x=x+0.1; » if (abs(x*x-2.0)<1e-6) printf("Should have used fabs()!\n"); » return 0;
}

Data

x (double)
128
4.94021057e-270

Memory

main()

128
129
130
131
132
133
134
135
x = 4.94021057e-270

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

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

x*x - 2 is 4.44089e-16
Close enough!
Should have used fabs()!
                                                                                                                                                                                                                                                                       

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