This line:
int n = GetInt();
tries to declare a new local variable n
. It's completely separate from the local variable you declared earlier:
int n;
When you call GetInt()
, you just want to assign the value to the existing variable, like this:
n = GetInt();