Created
May 15, 2025 14:28
-
-
Save DocBohn/ec42e6a6b091e3fa05debfcffd30b2c1 to your computer and use it in GitHub Desktop.
Code demonstrating K&R's motivating example for `continue` doesn't need `continue`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void process_nonnegative_elements(int a[], int n) { | |
int i; | |
for (i = 0; i < n; i++) { | |
if (a[i] < 0) { /* skip negative elements */ | |
continue; | |
} | |
// ... /* do positive elements */ | |
} | |
} | |
void process_nonnegative_elements_without_continue(int a[], int n) { | |
int i; | |
for (i = 0; i < n; i++) { | |
if (a[i] >= 0) { /* skip negative elements */ | |
// ... /* do positive elements */ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment