8. Ví dụ lệnh switch switch (c) { case 'a': case 'A': printf(“Dien tich = %.2f", r * r * pi); break ; case 'c': case 'C': printf(“Chu vi = %.2f", 2 * r * pi); break ; case 'q': printf(“Thoat"); break ; default : printf(“Chon khong hop le"); }
9.
10. Cấu trúc nhiều chọn lựa – switch biểu thức S 1 ; break; gt 1 … S 2 ; break; S e ; gt 2 default
11. Ví dụ khác – switch //Doan chuong trinh doc so 0..9 switch (so) { case 0: printf(“khong"); case 1: printf(“mot"); case 2: printf(“hai"); case 3: printf(“ba"); case 4: printf(“bon"); case 5: printf(“nam"); case 6: printf(“sau"); case 7: printf(“bay"); case 8: printf(“tam"); case 9: printf(“chin"); }
12.
13.
14.
15. Ví dụ do while int j = 5; printf("start"); do printf("j = %i", j--); while(j > 0); printf("stop"); start j = 5 j = 4 j = 3 j = 2 j = 1 stop