James Madison was the fourth president of the United States (1809-1817), and was the primary author of the Constitution.