Is it possible to ask the professor to check assignment before submitting? I have got assignments related to programming. They are tough and my friends could not get results. I wanted to ask my professor to run them to see whether I did them right or not. (the deadline is rapidly coming.)
I am a graduate student. It is my first term.
Most instructors will refuse to check your homework for you before you turn it in.  You get it graded once and only once.  There are no do-overs where you get to turn it in the first time, they point out your mistakes, then you get to turn it in again after you've corrected it.

If you're confused, you can ask clarifying questions about what the homework asks (e.g., desired behavior in corner cases, output formatting, error handling, other constraints and anything else that seems ambiguous) and about the underlying material (e.g., an algorithm discussed in lecture that you need to apply) but not about the correct answer or whether your answer is okay.  Some instructors (e.g., me) will help a student with debug, but usually only to help you learn the skills involved.  They usually will not debug your program for you.