The way to avoid anxiety, assuming it isn't a psychological condition, is to build confidence over the weeks (weeks!) leading up to the exam by using effective learning techniques.
Take effective notes and then summarize them in writing. Don't assume that if you have heard something once you should remember it. Active learning.
Work lots of exercises as appropriate. Get feedback on your solutions.
Ask questions as needed and record the results.
Don't cram the night before the exam. Get proper sleep. My most memorable F grade was after cramming much of the night before an open book test. Ugh.
If it is a psychological condition, your university probably has a counseling office that can provide advice.