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 complex root; » double value, err; » int expo; » printf("Please enter the number whose root is required\n"); » scanf("%lg", &value); » printf("Please enter the integer exponent\n"); » scanf("%d", &expo); » if (expo==0) { » printf("The zeroth root is mathematically undefined\n"); » return 1; } » root=cpow(value, 1.0/expo); » printf("The %dth root of %g is %g %+g i\n", expo, value, creal(root), cimag(root)); // Test » err=cabs(cpow(root, expo)-value); » printf("The absolute error is %g\n", err); » if (err>1e-12) { » printf("ERROR!\n"); » return 2; } » return 0;
}

Data

expo (int)   value (double)
132   136
-145183320
  
4.24399158e-312
err (double)   root (double complex)
144   152
-2.45864802e+267
  
-9.61809e+266
160
4.94394e-270

Where two numbers are shown the first is the real part, the second the imaginary.

Memory

main()

132
133
134
135
expo = -145183320
136
137
138
139
140
141
142
143
value = 4.24399158e-312
144
145
146
147
148
149
150
151
err = -2.45864802e+267
152
153
154
155
156
157
158
159
root(r) = -9.61809e+266
160
161
162
163
164
165
166
167
root(i) = 4.94394e-270

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

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

Please enter the number whose root is required
Please enter the integer exponent
The -145183320th root of 4.24399e-312 is 1 -0 i
The absolute error is 6.87245e-321
                                                                                                                                                                                                                                                                       

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