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)

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...
// Demonstrate inadvertant integer division
int main(){ » int j, k; » double x; // Simple division of two integer: » x=7/3; » printf("x: %g\n", x); // Same but with variables: » j=7; » k=3; » x=j/k; » printf("x: %g\n", x); // More-complicated case: » x=1.14159265358979+j/k; » printf("x: %g\n", x); // The reverse just throws away the fraction: » k=x; » printf("k: %d\n", k); // See what happens when we put "3.0": » x=7/3.0; » printf("x: %g\n", x); » return 0; }
...
Memory

main()

128
129
130
131
132
133
134
135
j = -144858627
k = 527344087
136
137
138
139
140
141
142
143
x = 2.01349078e+192

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

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: 2
x: 2
x: 3.14159
k: 3
x: 2.33333
                                                                                                                                                                                                                                                                       

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