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 complex arithmetic and the complex square root. //
int main(){ » double complex x, y, sqrtx; » x=1.2+3.4*I; » y=-13.7*x+5.6*x*x-12.7*I; » sqrtx=csqrt(x); » printf("x is %g %+g * I\n", creal(x), cimag(x)); » printf("y is %g %+g * I\n", creal(y), cimag(y)); » printf("sqrt(x) is %g %+g * I\n", creal(sqrtx), cimag(sqrtx)); » return 0; }
...

Data

x (double complex)   y (double complex)
128   144
3.25845e+266
4.26406e-139
  
-2.08144e+199
-4.26631e+136
sqrtx (double complex)
160
2.78888e-157
1.99121e+192

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

Memory

main()

128
129
130
131
132
133
134
135
x(r) = 3.25845e+266
136
137
138
139
140
141
142
143
x(i) = 4.26406e-139
144
145
146
147
148
149
150
151
y(r) = -2.08144e+199
152
153
154
155
156
157
158
159
y(i) = -4.26631e+136
160
161
162
163
164
165
166
167
sqrtx(r) = 2.78888e-157
168
169
170
171
172
173
174
175
sqrtx(i) = 1.99121e+192

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

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 is  1.2 +3.4 * I
y is  -73.112 -13.584 * I
sqrt(x) is 1.55009 +1.09671 * I
                                                                                                                                                                                                                                                                       

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