The only way I think that would happen would be if they were fairly weak to begin with and had a ton of performance anxiety, but I'd expect that to be exceptionally rare.
You could maybe pass the intro to CS class (mostly theory, not much programming), but unless you were willing to pay someone else to take tests for you there is absolutely no way you'd make it through data structures, or algorithms.
Even in an intro to MATLAB class I took that was designed primarily for non CS majors (mostly physics and biology majors) that substandard level of programming would have resulted in an F.
If one knows they will get zero if it does not compile (and they make this clear in the course), then I would be doing everything to remove code until it does compile and hope for some points versus none. I've seen some of the code snippets and it's just as bad as one would think. One person even wrote rude output statements when a user entered the wrong info (i.e. calling the person an "idiot" and such). Ironically, this person's code also did not compile.
The affirmation that almost 100% of grads can't write a trivial program would mean that somehow CS grads are worst at programming than a sample of random people.
Which language paradigm the question required? functional? logical? imperative? according the comment, they were phone interviews, meaning you had to dictate the program statements by phone, that's insane. It's impossible to take seriously those numbers.
Disclaimer: I have a CS degree, so my opinions are obviously biased :)
I used to be one of those people until I broke down and decided to finish my degree.
I think most of the people who speak out against college didn't go (or didn't finish) a STEM degree. I've seen both sides (history, and CS). Most of my previous criticism of college is applicable to history (at my institution at least), but not CS.
There are so many little holes that I've filled in that I didn't even know I had.
>The affirmation that almost 100% of grads can't write a trivial program would mean that somehow CS grads are worst at programming than a sample of random people.
You're right that something is off about that story. There is no way that someone could get through the entire program I'm going through without knowing how to write that for loop.
http://news.ycombinator.com/item?id=4603414
later confirmed here on HN by the hiring supervisor who observed the problem,
http://news.ycombinator.com/item?id=4919749
that many CS grads, even CS grads with master's degrees, can't get through a hiring screen that includes the question, "Write a loop that displays the numbers 1 to 100." Yes, something that simple is something too hard for many computer science graduates who are seeking jobs after graduation.
And that, ladies and gentlemen, is why you can't suppose that a computer science degree indicates ANYTHING about a job applicant's suitability to work for you. If you want to hire a programmer who will program well for you, test the job applicant's programming skill during the hiring process by having the applicant do a sample of the work you expect the programmer to do after the programmer is hired. In general, for hiring for any job, don't worry about degrees, but be sure to ask for a work-sample test.
References for why it's a good idea to hire on the basis of work-sample testing rather than on the basis of college degrees can be found in my extensive FAQ on the subject, written for Hacker News threads about hiring.
http://news.ycombinator.com/item?id=4613543
LAST EDIT: As I expected, people still don't believe this story. I thought it was rather amazing when I heard it. But, with further thought, I've decided that this really is an empirical issue. It may be that some jobs have less drawing power, and attract mostly applicants who are trying to get a green card to stay in the United States. (That seems to be one thing going on in the applicant pool for the job that had the hiring process, with two computers sharing screen views over the Internet as the applicant worked on the problem, described here.) The way to find out what applicants to the job you offer can do is to put them to a work-sample test, realistic for the job you want done. I hear that FizzBuzz is still screening out a LOT of applicants for some jobs,
http://www.globalnerdy.com/2012/11/15/fizzbuzz-still-works/
but FizzBuzz isn't a lot harder than "write a for loop," and certainly ought to be a job test that any CS graduate could pass. Try the people who next come to your workplace looking for a job, and see what they can do.