You'll need to declare
ypos as global variables, initialize them and not changing their values until you really need to.
Global variables are accessed from all the functions in your program. They never go out of scope until your program ends execution unlike local variables which might go out of scope after a code block, a loop, a condition or a function depending on where they are declared in your program.
ypos as global variables, you'll need to write something like this
// global variables
// we may initialize them here
xpos = 20;
ypos = 10;
// and update their values here
xpos = 10;
Global variables can also be initialized when they're declared, but it's a good practice to declare and initialize variables only when needed.
Update: I don't really see any point of your
swap() function. In fact, it doesn't do any swapping at all. I assume, you're trying to swap a tile at position (i, j) with the blank tile at position (xpos, ypos).
You don't really need to pass
ypos as arguments to
swap() in this case since they're already accessible from
swap(). That is, you can refer to them with their names (use them) directly within the function.
To "really" swap a tile at (i, j) with the blank tile at (xpos, ypos), you may have something like this
board[xpos][ypos] = board[i][j];
board[i][j] = BLANK; // where BLANK is the value of the blank tile
// update the position of the blank tile
xpos = i;
ypos = j;