Final answer:
James Madison was the 4th President of the United States and declared war during his presidency, which led to the War of 1812 in his second term.
Step-by-step explanation:
The President in question, who was in office during the War of 1812 and declared war, which occurred in his second term, is James Madison. Jefferson’s second term ended and James Madison's first term began just before the War of 1812 started. President Madison inherited the foreign policy issues of his predecessor, Thomas Jefferson, which included tensions with Great Britain and France due to the Napoleonic Wars.
This situation was exacerbated by British provocations such as the impressment of American sailors and their support for Native American resistance to U.S. westward expansion, ultimately leading to the declaration of the War of 1812 during Madison’s presidency.