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...
// // Count vowels and non-vowels // Demonstrates the switch statement. //
int main(){
  ...
» char hello[16]="Hello, world"; » int i, vowels=0, nonvowels=0; » for (i=0; helloi; ++i) switch (tolower(helloi)) { » case 'a': » case 'e': » case 'i': » case 'o': » case 'u': » ++vowels; » break; » default : » ++nonvowels; } » printf("The phrase \"%s\" contains %d vowels out of %d characters\n", hello, vowels, vowels+nonvowels); » return 0;
}
Memory

main()

128
129
130
131
132
133
134
135
i = -145067193
vowels = 0
136
137
138
139
140
141
142
143
nonvowels = 0
hello = 'H' 'e' 'l' 'l'
144
145
146
147
148
149
150
151
'o' ',' ' ' 'w' 'o' 'r' 'l' 'd'
152
153
154
155
'\0' '\0' '\0' '\0'

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

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

The phrase "Hello, world" contains 3 vowels out of 12 characters
                                                                                                                                                                                                                                                                       

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