Not OP but I'm teaching undergrad C. I'm assuming you have covered while loops before hand, if not, start there and cover the constructs with them that you would normally use a for loop for, example:
int i = 0; //a
while(i < 10) //b
{
printf("%d\n"); //c
++i; //d
}
and introduce for loops as a special case of the while loop: //a //b //d
for(int i = 0; i < 10; ++i)
{
printf("%d\n",i); //c
}
Then outline situations when you would use a for loop over a while loop, fixed number of repetitions, use with arrays etc.
Re:Git's list of banned C functions
by InvOfSmallC on Saturday March 06, 2021 @04:51AM
(#26366360)
Well I took the time and made some simple animation of how that works. For that and pointers I use animation so they can visualize what's happening. (Wasn't my idea, I googled it "how to explain pointers")
That is something I have a hard time convey as a teacher. My problem is that I have done this so long that I have no idea what there is not to understand about loops ... it's such a simple thing. But my (undergrad biology) students regularly have a hard time groking the concept no matter what explanation I use.