The 81-year-old Mr. Carter , the 39th U.S. president , served from 1977 to 1981 .