Why while loop printed 11

while

Because when num was 9, that meant num<=10 was true, so your while loop ran the num+=2 again.