I've tried your program and it works fine if I replace the scanf with getchar (for reading the answer).

b.t.w. you can also consider using the toupper function so the program also accept 'n' (lowercase).

Code:
while ( toupper(answer) != 'N');