/* * dowhile.c */ #include int main() { char cc; do // enter block test condition at the end. { printf("Enter a 'y': "); // prompt for input cc=getchar(); // read from stdin, assing to mem location of cc while(getchar() != '\n'); // keep running test on imput buffer until we get a new line . /* This embedded while test has a semicolon. * It gets characters and does nothing with them. * When it encounters a newline, it quits. */ printf("You entered a '%c'.\n",cc); // output result of getchar } while (cc != 'y'); // go back into loop unless cc = 'y' printf("Yes, a 'y', thank you. \n"); return 0; }