I recently learned that if the initial state is equal to the final state in the $p$-$V$ diagram then the internal energy is equal to zero so that means $Q=W$. My question is how can you know that only from the $p$-$V$ diagram without knowing the amount of Q? ( I'm taking generally not only in the case of ideal gasses)
Because U is a state funcion of P and V. This means that U isn't influenced by how a system arrived to a particular state (to a particular P and V) but just by the P and V that the system has at the moment. Therefor, if you draw a closed curve on the Clapryron plane, you will mean that (after some changes that U doesn't care about) you will be back with the same P and V, so the same U.
Also, note that you can say that U is constant, but you can't determine its value.