ete183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ete183... · 2017. 8....
TRANSCRIPT
![Page 1: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/1.jpg)
ETE183การเขยนโปรแกรมคอมพวเตอรสำหรบ
วศวกรรมไฟฟา
ผศ.ดร.วชราพรรณ แกวประพนธอ.ชนกชนม สงวรโยธน
![Page 2: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/2.jpg)
บทท 6 การทำซำ
![Page 3: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/3.jpg)
บทท 6
1. ทบทวนการใช if - else
2. กระบวนการการทำซำ
3. การใช for
4. การใช do - while
5. การใช while
![Page 4: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/4.jpg)
ทบทวนIf - else
1. วธการตโจทย
2. วธการเขยน OutputInputProcessVariable
3. วธเขยนประโยคเง7อนไขเพ7อใชกบ ifและelseif
4. วธการใช else5. วธการเปรยบเทยบคากบเสนจานวน
6. วธการเปรยบเทยบคากบตวอกษร
7. วธการเปรยบเทยบคากบขอความ
![Page 5: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/5.jpg)
การทาซ Hา หมายถง การส7งใหโปรแกรมทางานอยางใดอยางหน7งวนไปวนมา จนกระท7งครบตามจานวนท7ตองการหรอตรงตามเง7อนไขทเรากาหนดเอาไว
การทาซ Hาเกดข Hนบอยๆ ในชวตประจาวน เชน การวนรบรหสผาน จนกวาจะใสรหสผานถกตอง หรอไมเกน 3 คร Hง, การวนรบรหสบตรเตมเงนของบรการโทรศพท ไมเกน 3 คร Hง จนกวาจะใสรหสบตรเตมเงนถกตอง เปนตน
การทำซำ
![Page 6: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/6.jpg)
การทำซำ
แบบมจำนวนรอบทแนนอน เชน ตองการใหพมพตวอกษร a จำนวน 1000 ครงขนบนหนาจอ แบบนจะใช คำสง for
แบบใชเงอนไขเปนตวตดสนใจวาจะทำซำตอไปหรอไม ตองการใหโปรแกรมทำไปเรอยๆ ในขณะทเงอนไขยงเปนจรง อย เชน ใหรบรหสผานไปเรอยๆ จนกวาจะใสถก ซงจะไมมจำนวนรอบทแนนอนตายตว
ลกษณะนจะม 2 คำสงคอdo..while และ while
![Page 7: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/7.jpg)
หวใจสำคญของ
การวนรอบ
อะไรเปนตวกำหนดรอบ(เงอนไขในการวนรอบ)
อะไรเปนตวนบรอบ
อะไรเปนตวแทนการนบรอบนนๆ
![Page 8: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/8.jpg)
For การทำซำดวยวธการนบรอบ
![Page 9: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/9.jpg)
ใชในกรณท7เราตองการทาซ Hาโดยทราบจานวนคร Hงท7แนนอน เชน 20 คร Hง 30 คร Hง
การใชงานจะกาหนดลงไปเลยวาตองการใหทากคร Hง และจะตองสรางตวแปร ข Hนมาเปนตวนบ (counter)โดยมากจะกาหนดใหเปนตวแปรแบบจานวนเตม (integer)
ตวนบจะเปนตวคอยบอกวาครบตามจานวนทตองการรยง ถายงไมครบกจะวนไปเร7อยๆ จนกวาจะครบ
for
![Page 10: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/10.jpg)
for(คาเร7มตนของตวนบ ;
เปรยบเทยบตวนบวายงอยในชวงน Hหรอไม ;
จานวนนบเพ7มทละเทาไร หรอลดทละเทาไร){
คาส7งท7ตองการใหทา
}
ForForm
![Page 11: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/11.jpg)
for(คาเร7มตนของตวนบ ;
เปรยบเทยบตวนบวายงอยในชวงน Hหรอไม ;
จานวนนบเพ7มทละเทาไร หรอลดทละเทาไร)
คาเร(มตนของตวนบเชน n=0;
number=-5;a=b;
c=a+b;
For
![Page 12: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/12.jpg)
for(คาเร7มตนของตวนบ ;
เปรยบเทยบตวนบวายงอยในชวงน Hหรอไม ;
จานวนนบเพ7มทละเทาไร หรอลดทละเทาไร)
เปรยบเทยบตวนบวายงอยในชวงน :หรอไมเชน n>=0;
number<=-5;a>b;
c<123;
For
![Page 13: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/13.jpg)
for(คาเร7มตนของตวนบ ;
เปรยบเทยบตวนบวายงอยในชวงน Hหรอไม ;
จานวนนบเพ7มทละเทาไร หรอลดทละเทาไร)
จานวนนบเพ(มทละเทาไร หรอลดทละเทาไรเชน n++
number--a=a+2
c+=5
For
![Page 14: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/14.jpg)
การเขยนประโยคเงอนไขของ for
ถาหากตองการวน ตงแต 0 ถง 5 รวมทงสน 6 ครง
ไดแก 0 1 2 3 4 และ 5
เปนการเพมจำนวนขนเรอยๆจาก 0 ไป 5
สมมตใหตวนบรอบเปนตวแปร i
for(i=0 ; i<=5 ; i++)
ForForm
![Page 15: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/15.jpg)
for(i=0 ; i<=5 ; i++)รอบท 1 i จะมคาเปน 0
รอบท 2 i จะมคาเปน 1
รอบท 3 i จะมคาเปน 2
รอบท 4 i จะมคาเปน 3
รอบท 5 i จะมคาเปน 4
รอบท 6 i จะมคาเปน 5
แลวออกจากรอบการทำงาน
ForForm
![Page 16: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/16.jpg)
การเขยนประโยคเงอนไขของ for
ถาหากตองการวน ตงแต -3 ถง 3 รวมทงสน 7 ครง
ไดแก -3 -2 -1 0 1 2 และ 3
เปนการเพมจำนวนขนเรอยๆจาก -3 ไป 3
สมมตใหตวนบรอบเปนตวแปร j
for(j=-3 ; j<=3 ; j++)
ForForm
![Page 17: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/17.jpg)
for(j=-3 ; j<=3 ; j++)รอบท 1 j จะมคาเปน -3
รอบท 2 j จะมคาเปน -2
รอบท 3 j จะมคาเปน -1
รอบท 4 j จะมคาเปน 0
รอบท 5 j จะมคาเปน 1
รอบท 6 j จะมคาเปน 2
รอบท 7 j จะมคาเปน 3
แลวออกจากรอบการทำงาน
ForForm
![Page 18: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/18.jpg)
ตวอยางการใช forแสดงเลข 1ถง 10#include<stdio.h>main(){
int number;printf(“Start\n”);
for(number=1;number<11;number++){
printf(“%d\n”,number);}printf(“Stop\n”);
}
เรมตนให number=0
ทำในขณะท number<11
เพมคา number ทละ 1number = number+1
![Page 19: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/19.jpg)
ผลรนโปรแกรมStart12345678910Stop
จะสงเกตวา โปรแกรมจะแสดงคาของตวแปร number โดยใหคาของ number เรมตนท 1 แลววนรอบไปเรอยๆ จนถง 10
![Page 20: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/20.jpg)
ตวอยางการใช for แสดง hello 10 ครง#include<stdio.h>main(){
int count;printf(“Begin\n”);
for(count=0;count<10;count++){
printf(“Hello\n”);}printf(“End\n”);
}
เรมตนให count=0
ทำในขณะท count<10
เพมคา count ทละ 1count=count+1
![Page 21: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/21.jpg)
ผลรนโปรแกรมBeginHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloEnd
คำวา Hello จะถกแสดงทงหมด 10 ครง โดยทตวแปร count คอตวแปรทใชเปนตวนบ เราใหคาเรมตนเปน 1 และจะเพมคาขนทละ 1 ไปเรอยๆ ในขณะทตวแปร count ยงนอยกวา 10 แตถาตวแปร count เทากบ 10 เมอไร เงอนไขจะเปนเทจ โปรแกรมกจะหลดออกจากคำสง for ทนท
![Page 22: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/22.jpg)
โปรแกรม แสดงสตรคณแม 6#include<stdio.h>main(){
int mother=6;int count;printf(“Begin\n”);for(count=1;count<=12;count++){
printf(“%dx%d=%d\n”,mother,count,mother *count);}printf(“End\n”);
}
![Page 23: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/23.jpg)
การทำงานของ For
ไมจำเปนตองนบไปขางหนา (+) เสมอ
สามารถนบถอยหลงกได เชน
for(count=12;count>=1;count--)
For
![Page 24: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/24.jpg)
dowhile
การทำซำดวยวธการตรวจสอบเงอนไขหยดทำซำกตอเมอเงอนไขผดแบบทำกอนตรวจ
![Page 25: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/25.jpg)
คำสง while และ do..while จะตางจากคำสง for เลกนอยตรงทการทำซำแบบน ไมจำเปนตองบอกถงจำนวนรอบของการทำซำ แตละทำซำไปเรอยๆ จนกวาเงอนไขจะเปนเทจ
do-while
![Page 26: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/26.jpg)
do{
คาส7งหรอกลมคาส7งท7ตองการใหทาซา
}
while(ประโยคเง7อนไข);
do-whileจะไมเชคเง(อนไขในคร:งแรกกอนทา
do-whileForm
![Page 27: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/27.jpg)
ตวอยางการใช do-while#include<stdio.h>main(){
charout=‘’;do{
printf(“\nDoyouwhattoexit?[Y]es or[N]o:”);scanf(“%c”,&out);
}while(out!=‘y’);
}
กอนเขาสการตรวจสอบเงอนไข(out!=‘y’) ครงแรกนนจะมการทำคำสงใน {} กอน ดงนน do..while จงทำคำสงภายใน {} อยางนอย 1 ครงเสมอ และถาตรวจสอบแลวเงอนไขยงจรงอยกจะวนมาทำคำสงภายใน {} อกครง
![Page 28: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/28.jpg)
while
การทำซำดวยวธการตรวจสอบเงอนไขหยดทำซำกตอเมอเงอนไขผดแบบตรวจกอนทำ
![Page 29: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/29.jpg)
while(ประโยคเง7อนไข){
คาส7งหรอกลมคาส7งท7ตองการใหทาซา
}
whileจะเชคเง(อนไขในคร:งแรกกอนทา
whileForm
![Page 30: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/30.jpg)
ตวอยางการใช while
#include<stdio.h>main(){
int count=1;
while(count<=10){
printf(“Hello%d\n”,count);
count++;}
}
จากตวอยางเรากำหนดให count มคา เปน 1 จากนนใชคำสง while ตรวจดคาของ count วายงนอยกวาหรอเทากบ 10 หรอไม ถาใชกยงทำคำสงภายใน{} ตอไป และเพมคา count ทละ 1 ไปเรอยๆ จนกวาคา count จะมากกวา 10 ทำใหเงอนไขเปนเทจกจะหลดจากลป while
![Page 31: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/31.jpg)
-
ลองทำโจทย
1. จงเขยนโปรแกรมแสดงสตรคณแม 2โดยใช do-while
2. จงเขยนโปรแกรมแสดงสตรคณแม 2โดยใช while
3. จงเขยนโปรแกรมแสดงสตรคณแม 2โดยใช for
![Page 32: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/32.jpg)
ยกตวอยางจากโจทย “ลกนง”
![Page 33: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/33.jpg)
•ท Hงหมดท7กระทาเราทาท Hงหมดก7รอบ ?•คาส7งน H ผลกระทาเหมอนกบคาส7งท7แลวหรอไม•คาส7งน H แตกตางจากคาส7งท7แลวอยางไร•ส7งท7เราตองจดจา คออะไร ?•เรารไดอยางไร วาเราทาครบ 3คร Hงแลว ?
![Page 34: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/34.jpg)
ลองเขยน Flowchart ด
แบบท% 1
int num;for(num=1;num<=3;num++){ลก;น:ง;น:งพ=น;น:ง;
}
แบบท% 2
int num=1;while(num<=3){ลก;น:ง;น:งพ=น;น:ง;num++;
}
![Page 35: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/35.jpg)
•เราทาไปท Hงหมดก7รอบ ?•อะไรเปนตวกาหนดรอบ ?•เง7อนไขท7ใชในการกาหนด คออะไร ?
![Page 36: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/36.jpg)
-
do{ ลกน:ง;
scanf(“เสยงอาจารย”,&คาส:ง);}while(คาส:ง!=“หยด”);
ลองเขยน Flowchart ด
![Page 37: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/37.jpg)
•อะไรคอเง7อนไขท7ทาใหเราลกน7งตามจานวนทกาหนด
•เรารไดอยางไร วาเราทาครบ 5คร Hงแลว ?•เราจะหยดลกน7งตอเม7ออะไร ?
![Page 38: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/38.jpg)
-
int nub;for(nub=1; nub<6; nub=nub+1){ลกน:ง;
}
ลองเขยน Flowchart ด
![Page 39: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/39.jpg)
•คาส7งน H ผลกระทาเหมอนกบคาส7งท7แลวหรอไม
•คาส7งน H แตกตางจากคาส7งท7แลวอยางไร
•ส7งท7เราตองจดจาในทกๆรอบ คออะไร ?
![Page 40: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/40.jpg)
แบบท% 1int count = 0;do{ลกน:ง;count = count + 1;
}while( count != 5 );
แบบท% 2int count = 0;while(count != 5){ลกน:ง;count = count + 1;
}
![Page 41: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/41.jpg)
• คาส7งน H มกระบวนการอะไรบาง
• อะไรคอ Memory จดจา
• อะไรคอ Input รบขอมล
• อะไรคอ Process ประมวลผล
• อะไรคอ Output แสดงผล
![Page 42: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/42.jpg)
-
ลองเขยนโปรแกรมดเอง
การหาคาเลขค เลขคเราใชการหารเอาเศษกบ 2อะไรทหาร 2 แลวไดเศษ 0แสดงวาเปนเลขค
เชนAns = A % 2;if(Ans == 0)
![Page 43: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/43.jpg)
-
Research
คนหา1.ความแตกตางระหวาง
การใช do-while และ while2.วธการเพมคาขนเรอยๆจากการวนโดยเพมขนรอบละ 1 (x+=1)ปล.ใชตอบคำถามใน Quiz
![Page 44: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/44.jpg)
ExtraResearch
กลบไปลองหาและทำโจทยทใช if-else รวมกบการวนรอบใน
do-while หรอ forปล.ใชตอบคำถามใน Quiz
![Page 45: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/45.jpg)
-
QuizQuiz บทท 6 และ 7กอนเขาเรยนครงตอไป
![Page 46: ETE183 บทที่ 6ete.tido.tech/ete-programming/student/tutorials/ETE183... · 2017. 8. 30. · คำสั่งwhile และ do..whileจะต่าง จากคำสั่งfor](https://reader035.vdocuments.mx/reader035/viewer/2022081407/60555c4c021d885e961729a9/html5/thumbnails/46.jpg)
-
การบานLecture
Learning Report+
Hour of CodeMinecraft AngryBird Frozen