I had a problem like yours that mysteriously cropped up my sophomore year. I just flat-out stopped doing work, and I would skip a lot of classes.
The cause was that I had one absolutely horrendous teacher who managed to strip me of my passion for computer science and at the same time depressed me to the point of giving up on all of my classes.
I lucked out in that I can fly by the seat of my pants well enough to get good grades without working...I got an F from this clown, but As and Bs in my other classes.
Don't let this happen to you. Recognize the cause and drop the offending class, or get the help you need to get through it.
Hopefully you go to a big enough school where you can take the class with a different teacher.
I was able to retake the class with a different teacher. I got a B-.
Unfortunately, I had the same teacher for another class. This time, recognizing the danger, I worked extremely hard both to keep my spirits up and to do the work as best I could. I handed in every lab early, I even aced the first of 3. My final lab was 20 printed pages of COMPILED code and he gave me a 20 out of 100. 20! You would think a fully-written and compiled program would be good for AT LEAST half credit.
And so, despite my hard work I got ANOTHER F. I will point out that my lowest grade in ANY CS class before this was B+. I'm not exactly a poor student.
I ended up having to take a takehome test (which I aced, BTW) and they "generously" allowed me to accept a D if I passed it.
And, I was going to have this teacher for ANOTHER class. The dept. chair and dean wouldnt' recognize the teacher as the problem (surprise, surprise), and at the end, I actually had to have my mom call the school (WTF am I, in 5th grade?). Not surprisingly, the runaround suddenly stopped, and I was suddenly pre-approved to take the corresponding class at NJIT, which, I might add, I did minimal work in, and I got an A.
I still think I should have sued the college for the cost of the NJIT course and having to retake the first class I failed.
And people wonder why I'm disillusioned at the higher-education business.