Question: who was the president when the national anthem was written
Answer: President James Madison