Maker Pro
Maker Pro

define a variable in header file

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
Please try to find out by yourself. You'll learn much more by this.
To do so, simply follow the instructions manually - easy as there aren't many:

Check the variables i, start, last, temp and array[] at each step - simply write the contents on a piece of paper to trace the program flow.
For i=0, 1 and 2 the program obviously delievers the correct output.
Watch especially what happens when i reaches the values i=2, i=3.
The case i=4 is then trivial.
This should make it obvious to you where the error is.
 
Top