Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Incorrect loop conditions in C
#1
Using incorrect loop conditions can lead to infinite loops or incorrect program behavior.

// Incorrect
int i = 0;
while (i <= 5) {
    printf("%d ", i);
    // Missing increment of 'i' (i++ or i--)
}

// Correct
int i = 0;
while (i <= 5) {
    printf("%d ", i);
    i++;
}
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using incorrect format specifiers in C Qomplainerz 0 194 07-26-2023, 07:11 AM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: 1 Guest(s)