24 do – while loop


  • syntax
    do {
       /* statement */
    } while( condition ) ;

  • จะทำในบล๊อกก่อนอย่างน้อย 1 ครั้ง
  • do – while จะจบด้วย ; ( semicolon )

#include <stdio.h>
int main(void)
{
int i = 100,choice;
setbuf(stdout,NULL);
do{
printf("1.) Cappuccino\n");
printf("2.) Late\n");
printf("3.) Expresso\n");
printf("4.) Macchiato\n");
scanf("%d",&choice);
}while(choice >= 1 && choice <= 4);
return 0;
}
view raw B24_Do_while.c hosted with ❤ by GitHub