News for hackers. Stuff that matters.
Re:Git's list of banned C functions by dave84 on Friday March 05, 2021 @05:49AM (#26355366)
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.

There are no comments on this comment yet.