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...
#define N 8
int main(){
  ...
» int x[N]={8,6,3,5,7,1,4,2}, i, j, tmp; » for (i=0; i<N; ++i) { » for (j=i+1; j<N; ++j) { » if (xj<xi) {// swap them » tmp=xi; » xi=xj; » xj=tmp; } } } » for (i=0; i<N; ++i) printf("%d\n", xi); » return 0;
}
Memory

main()

128
129
130
131
132
133
134
135
i = 153170280
j = 134537954
136
137
138
139
140
141
142
143
tmp = 134537758
x[0] = 8
144
145
146
147
148
149
150
151
x[1] = 6
x[2] = 3
152
153
154
155
156
157
158
159
x[3] = 5
x[4] = 7
160
161
162
163
164
165
166
167
x[5] = 1
x[6] = 4
168
169
170
171
x[7] = 2

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

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

1
2
3
4
5
6
7
8
                                                                                                                                                                                                                                                                       

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