Praise be to Allah.
No one should vow to do anything. Whoever wants to do an act of worship should do it without making a vow, because by making a vow he makes this act of worship obligatory upon himself, and he exposes himself to sin and shortcomings and deserving the punishment if he does not fulfil what he vowed to do. It is proven that the Prophet (peace and blessings of Allaah be upon him) told people not to make vows.
See also the answer to question no. 67886.
If what you mean is that you vowed to fast if you passed your exams, and you did pass, praise be to Allaah, then you have to fast, because the Messenger (peace and blessings of Allaah be upon him) said: “Whoever vowed to do an act of worship, let him fulfil his vow.” Narrated by al-Bukhaari (6696). If you are unable to do it because of sickness and the like, then you have to offer expiation for breaking an oath (kafaarat yameen), because the Messenger (peace and blessings of Allaah be upon him) said: “Whoever makes a vow to do something that he is not able for, his expiation is kafaarat yameen.” Narrated by Abu Dawood (3322) from the hadeeth of Ibn ‘Abbaas. Al-Haafiz said in al-Fath: Its narrators are thiqaat, but it was narrated by Ibn Abi Shaybah in a mawqoof report. Ibn Qudaamah said in al-Mughni (10/72): Whoever vows to do an act of worship that he cannot do or is able to do it but fails to do it has to offer kafaarat yameen.
See: Fataawa al-Lajnah al-Daa’imah (23/201).
But if what is meant is that you resolved to fast, without saying words such as vowing or promising, then you do not have to do anything in that case, because a vow does not become binding by mere intention, rather it must be spoken.
It says in al-Muhadhdhab: A vow is not valid unless it is spoken.
Al-Nawawi (may Allaah have mercy on him) said in his Sharh: Does a vow count if it is intended and not spoken? The correct view, according to the consensus of our companions, is that it does not count unless it is spoken. Intention alone does not count (as a vow). End quote from al-Majmoo’ (8/435).
It says in al-Insaaf (11/118): A vow does not count unless it is spoken. If he intends it without speaking, then it is not counted as a vow, and there is no dispute on this point.
And Allaah knows best.