K&R C Exercise 2-2: Loop Without && or ||
Exercise 2-2. Write a loop equivalent to the for loop below without using && or ||: for (i = 0; i < lim – 1 && (c = getchar()) != ‘\n’ && c != EOF; ++i) s[i] = c; Understanding the Problem The && operator in C is a short-circuit operator: if the left operand …