Until you fix the first scanf, I can't see it doing anything but skip reading n.

> is said to be undefined....
Your parameter is x, yet you use n.