Try printing out a copy of your program, grab some paper and a pencil. Sit down at a desk or a table.
Start at the first executable statement in main()
and follow the program statement by statement. Write down the values of all variables. Write down everything that is displayed. IOW, you be the computer and desk-check your program.
This is a fundamental part of programming -- checking your work.