Skip to content

Instantly share code, notes, and snippets.

@gcr
Created February 22, 2009 03:17
Show Gist options
  • Save gcr/68315 to your computer and use it in GitHub Desktop.
Save gcr/68315 to your computer and use it in GitHub Desktop.
// Sentinel-controlled loop
// User will enter up to MAXSCORES test scores, or a -1 to finish.
// This loop cannot use breaks.
do {
printf("Score %d: ", *nScores+1);
scanf("%d", &userResponse); // Get the response
if (userResponse >= 0) {
scores[*nScores] = userResponse; // Save it
*nScores = *nScores + 1;
}
} while ((userResponse >= 0) && (*nScores < MAXSCORES));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment