Have an Answer?
Study, study, study.
It's recommended you spend four hours studying (not counting class time) each week for each unit a course is worth. So if your course is worth four units, you'd want to aim for spending 16 hours of study time each week.
Try out different study methods to try and find which one works best for you. Study with a group, study alone, use flash cards, listen to recorded lectures, read the text, make your own notes, quiz yourself, quiz your friends, do practice problems (probably one of the best ways to prepare for most classes).
Become a regular at office hours, not only will it force you to read up the material before attending, but you'll be able to make good connections that may lead to a letter of recommendation in your future.
Don't be afraid to ask for help, if office hours aren't enough time, see if your school has tutoring (many schools offer this service for free).
Most importantly, never give up. We all have bad exams, and some of us even have bad courses. Never let one bad test keep you down, instead look at it as an opportunity to get better in the future. Ask yourself what went wrong and what you can do to do better next time.