C: Weird conditional printf behavior [closed]

There is one semicolon after the if statement that is causing the problem. if (i!=0); { //this will always execute } change it to if (i!=0) { //this will execute if i != 0 } The compiler does not warn you because the first statement is syntactically valid.