What you went through was a panic episode during which you felt intense physical and psychological symptoms of anxiousness. You seem to be under a lot of stress because of your exam preparation, as you have stated. Persistent/chronic stress raises the likelihood of developing a number of medical and psychiatric disorders. It appears from what you have said that you are experiencing symptoms of depression and anxiety which needs to be evaluated thoroughly and seek treatment for.
A number of basic brain processes/cognitive functions of brain are also impacted when a person suffers from chronic stress- various neurotransmitter imbalances are the culprit. Your general performance and cognitive skills, such as memory, reasoning, and attention, will both improve with the appropriate management.
Next Steps
Consult a psychiatrist. Take a leap of faith, with treatment your feeling and thinking state will change for the better and productivity will improve. Good luck and all the best.