Syntax errors can significantly impede students' progress and comprehension of programming concepts. AI-generated programs are also prone to syntax bugs, highlighting the importance of effectively addressing and resolving such errors. This paper presents Iaso, an automated program repair tool designed specifically to rectify syntax errors in student and AI-generated C programs. Iaso consists of three components: a syntax-based C program generator, an error localization model, and an ensemble code corrector. The program generator is trained on a seed dataset to generate complete and compilable C programs, which are then used to train the corrector. The corrector, trained on a combination of the seed dataset and a synthetic dataset, adopts an ensemble approach to gather fixes from multiple correctors trained on different datasets. During the repair process, Iaso's error localization model utilizes information from the deep learning model, raw code, and compiler messages to precisely identify the required repairs. To evaluate our method, we compare it against two automated program correctors: DrRepair and TransRepair. Iaso demonstrates notable performance, achieving a full repair rate of 78.8\% (+4.2\%) on the Deepfix test set and 91.0\% (+6.8\%) on the Tracer test set, generating over 1,300,000 erroneous C programs. Compared to the large language model PaLM, our strategy showcases a significant 6\% improvement in accuracy, considering the unlimited edit size used by PaLM. Furthermore, when compared to the state-of-the-art dialogue model ChatGPT, our method exhibits only a slight 1.4\% deviation while utilizing significantly fewer resources.