There are a few things most programming professors expect in the code that is handed in to them. In my experience professors like code that is clean, well commented, and has no tab damage as well as anything that is required by the college, such as an honor pledge. Obviously another thing professors like is code that compiles and does what is required for the assignment.
Writing well commented code is a must, especially when you get into programming in a team of programmers. A general rule is that if it was at all hard for you to write, comment it. I recently got a job developing in C#. I came in on a project and there were no comments at all, for any of the code. As such, it took me about twice as long to read though the code and try to understand it. As far as school goes, I've had professors say they will not grade an assignment if there are no comments and that about 15% if your grade on said assignment was for good comments and clean code.
I've had one professor that would dock points for tab damage. What is tab damage you ask? Tab damage is when you use tabs instead of spaces to indent your code. All text editors handle tabs differently. Some of them will set a tab to be equal to 5 spaces, or 3 spaces, or 7 spaces etc. Say you are writing code in a text editor where a tab is only 3 spaces, and your professor opens your code in a text editor where a tab is 7 spaces. In your professors text editor your code will look terrible because of the giant indents. A way to avoid this is to set a tab in your text editor to insert a give number of spaces instead of a tab character. All text editors treat spaces the same, so no damage from tab characters. Some professors care about this and some don’t. Also most IDE’s will take care of this for you.
Honor Pledges. Make sure they are there if your professor is requiring one. These basically say “I didn’t steal this code in whole or in part”. This keeps students from cheating on their assignments. Worried about collaborating with other students or friends? Usually the college will have a policy on this, and have an area in the honor pledge to put who you worked with. There is nothing worse than working on an assignment and then getting a 0 because you forgot to include the honor pledge in your code.
Code that compiles is a must as well. If you are having trouble, don’t be afraid to ask your professor to point you in the right direction. They are there to help you. Another thing to watch out for is if you comment your code once you are done (you should really be doing it as you code) make sure your code compiles and runs after you make comments. Never know, you might have accidentally deleted a semi-colon, or forgot a /.
A lot of what I just talked about is dependent on your professor, and how strict they are, but if you plan on getting a job programming you should take hold of good programming practices. As I’ve heard, write your code as if the person that will be reading it is a crazy psychopath that knows where you live.