Compile error: Hierarchical reference to automatic variable is not legal

In reply to dave_59:

let me check and reply back…it actually passed compile when I replaced

int k = j%2;

with

int k;
k = j%2;