You have raised an interesting question. First of all, let me commend you for two things: your desire to turn to Allah for help; secondly, for your desire to pass your exam. Both are indeed noble goals; for as Muslims we need to be always turning to Allah, and aspire for success in our studies and career goals.
Now coming straight to the issue: Islam teaches us that we must pray to Allah while putting forth the best of our efforts. Our perfect role model is the Messenger of Allah, who succeeded where no one else succeeded; for within a short span of 23 years he won over his enemies and brought all of Arabia under the rule of Islam. How did he do this? Not simply through prayer; rather by combining prayer with hard work. He put forth the best of efforts and then turned to Allah. He told us to do the same, "Always strive for goals that are beneficial for you, expend your utmost efforts and seek for the help of Allah and do not feign helplessness." (Reported by Muslim on the authority of Abu Hurayrah)
So let me ask you: did you do your best to study? Do you have good study and work habits? Did you pay attention in your class, and take proper notes? Or did you occupy your mind with all sorts of frivolities? If the latter is the case, then you have no right to expect Allah to give you success, for Allah helps only those who help themselves. Allah has given us all the resources to succeed in life; if we use them efficiently and turn to Him, He will grant us success. If, however, we neglected to use them and yet hope for Allah to come to our help, we are simply day dreaming: The Prophet (peace be upon him) never sat idle a single day; he worked hard and prayed to Allah. Once a nomad came to him and told him, "I have left the camel in the desert to wander putting my trust in Allah to take care of it!" The Prophet (peace be upon him) immediately responded, "No; first, you ought to tie your camel, and then put your trust in Allah!" (Reported by Tirmidhi on the authority of Abu Hurayrah)
Prayer without using the God-given resources to help ourselves is like mocking Allah. Prayer is not a lazy man's vain wishes; it is the heart turning to Allah after having exhausted all of its efforts to help himself or herself. It is like someone saying to Allah: "O Allah, You know I have put forth all of my efforts; now I turn to You and You alone to grant me success!" Allah says, "Those who strive in Our Cause, We shall certainly guide them unto Our Ways. Indeed, Allah is with those who excel in their work." (Qur'an: 29:69). The Prophet ( (peace be upon him) said, "Allah wants you to seek to excel in the work you set out to do." (Reported by Bayhaqi in Shu'ab al-iman)
Therefore, I urge you to learn good study/work habits, shake off your laziness, overcome bad habits, work hard, and then pray to Allah. Allah will love you and grant you success.
For further details on empowering yourself, please consult the following answer.