I am trying to create a C program question, where I expect student to write complete program and use dynamic memory allocation using malloc. In Python, I have used template grading to check for certain conditions e.g. if student used list comprehension or not etc. Can anyone help with similar tests that we can perform for a C question.
If you use a Python-scripted C question as explained in the section on implementing new languages, you can perform any checks you like on the student's answer before compiling and running it.
We've recently developed a C question type scripted in Python that uses astyle for checking style and layout, the Python pycparser module for parsing the student's program (letting us do things like check for certain constructs being used and to limit the number of lines per function) and can optionally run the student's code with valgrind. I can let you have it if you like but frankly it's way too complicated (around 900 lines of Python) and I think you'd be better off developing your own question type that just does what you want.