This happens because the compiler goes through the program line by line from top to bottom. So when you check for the "marks" value with your if statements it has the value of 0 and the "grade" is...