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 the trigonometric identity // cos(a+b) equals cos(a)*cos(b) - sin(a)*sin(b) //
int main(){ » double mummy_bear, daddy_bear, baby_bear, porridge; » mummy_bear=0.707;//! Random values » daddy_bear=0.1234; » baby_bear=cos(mummy_bear)*cos(daddy_bear) -sin(mummy_bear)*sin(daddy_bear); » porridge=baby_bear-cos(mummy_bear+daddy_bear); » printf("I calculate cos(%g) to be %g\n", mummy_bear+daddy_bear, baby_bear); » printf("with an error of %g\n", porridge); » return 0; }
...

Data

mummy_bear (double)   daddy_bear (double)
128   136
-2.0814446e+199
  
-1.8606102e+136
baby_bear (double)   porridge (double)
144   152
2.78888424e-157
  
1.42536367e+192

Memory

main()

128
129
130
131
132
133
134
135
mummy_bear = -2.0814446e+199
136
137
138
139
140
141
142
143
daddy_bear = -1.8606102e+136
144
145
146
147
148
149
150
151
baby_bear = 2.78888424e-157
152
153
154
155
156
157
158
159
porridge = 1.42536367e+192

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

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

I calculate cos(0.8304) to be 0.674581
with an error of -1.11022e-16
                                                                                                                                                                                                                                                                       

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