You want to start with num=1 and say while (num <= 3), since you are using num++. As it is, num goes 3, 4, 5, 6, ... and is always greater than 1, so you loop a long time, but you only print for 3 because your switch statement always covers 1, 2, 3. You could also change the num++ to num--, but that would cause your output to be in the order 3, 2, 1 instead of 1, 2, 3.
No comments:
Post a Comment