There are three difference: 1) storage duration ; 2) scope 3) and linkage of variables.
In the first example variables a, b, sum have static storage duration and are zero initialized. They have the global scope and external linkage.
In the second example these varaibles have automatic storage duration, have undefined values and the block scope. They have no linkage.