I was just the TA for a CS class. I don't know any students, even the ones who struggle the most in the Introductory CS sequence, who can't do that. I'd say even those that failed the course can probably do that...
But what level institution are you at? I can easily imagine weak second and third tier CS students who can't code their way out of a paper bag. It looks like Reddit's r/cscareerquestions/ gets questions from a lot of these type of people.
I have a hard time believing the claim. I've certainly seen a fair share of new graduates disappointingly lacking in certain areas (for some reason, this seems to be especially true of those who hold a Masters degree but have no work experience), but managing to graduate without knowing how to do a simple for loop is really, really hard to believe.
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.
I'm at a run of the mill state school (Georgia State--returning after a 6 year hiatus), and I can't imagine how someone who couldn't write that for loop could graduate.
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.
I am at a top 10 UK university. One of the people I have been assigned to work on a group project with would probably fail this question, we are end-of-second year students.
I have a friend I've mentored through their CS degree and they're now a grader for a course. They tell me constantly about some students they have to give zeros to because their simple assignments (2nd level programming course) do not compile.
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.