วันเสาร์, มิถุนายน 28, 2025
Latest:
วิชาการเขียนโปรแกรมด้วยภาษาซี (c)

คำสั่ง while ภาษาซี c programming

การควบคุมทิศทางการทำงานแบบวนรอบ หรือจะเรียกว่าการทำงานแบบวนลูป สำหรับคำสั่ง while เป็นคำสั่งที่จะเริ่มต้นทำงานโดยการตรวจสอบเงื่อนไขก่อน หากเงื่ออนไขเป็นจริง จะทำตามคำสั่ง while ทำงานจนกว่าจะตรวจสอบเงื่อนไขแล้วพบว่าเงื่อนไขเป็นเท็จจึงจะออกจากลูปการทำงาน


รูปแบบคำสั่ง

while (เงื่อนไข){
งาน
}


ตัวอย่างคำสั่ง while ภาษาซี (c)

#include <stdio.h> 
main() 
{
int i = 0;
while (i < 10)
 {
  printf ("i =%d\n",i);
  i++;
}
}

ผลลัพธ์ที่ได้

i =0
i =1
i =2
i =3
i =4
i =5
i =6
i =7
i =8
i =9

slot gacor hari ini slot qris slot gacor maxwin slot online slot gacor gampang menang slot gacor hari ini slot online slot slot slot majapahit77 majapahit77 guci777 guci777 wortel21 wortel21 guci777 sodo66 agen138 slot agen138 slot data hk