Using a Sentinel to End a while Loop
#include <stdio.h>
main ( )
{
float average;
int counter, grade, total;
total = counter = 0;
/* tell user the sentinel value in the prompt*/
printf (“Enter grade, -1 to end : “);
scanf (“%d”, &grade) ; /* priming read */
Previous slide
Next slide
Back to first slide
View graphic version