SlideShare uma empresa Scribd logo
1 de 28
 
Control Statements ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],if statement ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
if  statement Statement 1 expression Statement 2 false true expression Statement 3 true Statement 2 false Statement 1 แบบที่  1 แบบที่  2
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],ถ้ามีตัวเลขไม่ซ้ำค่าติดบนลูกบอล  5  ลูก ใส่ไว้ในถุงดำแล้วให้หยิบมาที ละลูกเพื่อหาลูกที่มีค่ามากที่สุดและน้อยที่สุด คำถาม  จะต้องหยิบกี่ครั้ง และ มีวิธีการอย่างไรในการหาลูกที่น้อยที่สุดและมากที่สุด
MAX =  MIN =  1 ถ้ามีตัวเลขไม่ซ้ำค่าติดบนลูกบอล  5  ลูก ให้หาเลขที่น้อยที่สุดและมาก ที่สุดที่ติดบนฟุตบอล จะทำอย่างไร  !!!
MAX =  MIN =  2 ถ้ามีตัวเลขไม่ซ้ำค่าติดบนลูกบอล  5  ลูก ให้หาเลขที่น้อยที่สุดและมาก ที่สุดที่ติดบนฟุตบอล จะทำอย่างไร  !!!
MAX =  MIN =  3 ถ้ามีตัวเลขไม่ซ้ำค่าติดบนลูกบอล  5  ลูก ให้หาเลขที่น้อยที่สุดและมาก ที่สุดที่ติดบนฟุตบอล จะทำอย่างไร  !!!
MAX =  MIN =  4 ถ้ามีตัวเลขไม่ซ้ำค่าติดบนลูกบอล  5  ลูก ให้หาเลขที่น้อยที่สุดและมาก ที่สุดที่ติดบนฟุตบอล จะทำอย่างไร  !!!
MAX =  MIN =  5 ถ้ามีตัวเลขไม่ซ้ำค่าติดบนลูกบอล  5  ลูก ให้หาเลขที่น้อยที่สุดและมาก ที่สุดที่ติดบนฟุตบอล จะทำอย่างไร  !!!
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
For statement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],int  i, j; for  ( i = 5, j = 10 ;  i + j < 20 ; i++, j++ )   cout<<&quot; i + j =  &quot;<<  (i+j)  <<endl;
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
เขียนคำสั่ง   For statement  แสดงผลดังนี้
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
แสดงอุณหภูมิเซลเซียส และฟาเรนไฮต์ โดยที่ Fahreheit =9*Celseius /5+32
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
while..do and  do…while ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],while …do รับค่า จำนวนเต็ม ตั้งแต่  0 – 9  สิบจำนวน แล้วหาว่ามี ตัวเลขคู่ และ คี่ กี่จำนวน  … while do
while..do and  do…while ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],do…..while  รับค่า จำนวนเต็ม ตั้งแต่  0 – 9  สิบจำนวน แล้วหาว่ามี ตัวเลขคู่ และ คี่ กี่จำนวน  ... do…while
หาค่า  j k l  กรณี  มี และไม่มีคำสั่ง  break  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
#include < iostream .h> float  power3 (float); void main (void) { int i ; for (i=1; i <=10; i++) cout<< i<<“  “<<power3 ( i )   ); } float  power3 (float  x ) { return  x *  x   * x ; } ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Function
[object Object],#include <iostream . h> void main () { int i, j, n; cout << &quot; Enter N  = &quot; ; cin >> n; i  =  n; while  ( i >=   1 )  { j  =  1; while  ( j < i )  { cout <<  &quot; &quot; ; j ++ ; } while  ( j < =  n )   { cout <<  &quot;*&quot; ; j ++ ; } cout <<  &quot;  &quot; ; i--; } } #include <iostream . h> void main () { int i, j, n; cout << &quot; Enter N  = &quot; ; cin >> n; for  ( i = n;i> = 1;i --) { for  ( j = 1;j<i;j ++)   cout <<  &quot; &quot; ; for  ( j = i;j< = n;j ++) cout << &quot;*&quot; ; cout <<  &quot;  &quot; ; } } เปรียบเทียบ การใช้  While  และ  For loop
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],ให้นักศีกษาเขียนโค๊ดโปรแกรมแล้วทำการรันว่าได้ค่าอะไร  แล้วตอบคำถามว่า โปรแกรมที่ทำงานอย่างไรเขียนขึ้นมาเพื่ออะไร

Mais conteúdo relacionado

Destaque

Slavery in the colonies
Slavery in the coloniesSlavery in the colonies
Slavery in the coloniesteresagreer
 
Philosophical Issues and Ideas
Philosophical Issues and IdeasPhilosophical Issues and Ideas
Philosophical Issues and Ideasguestcc1ebaf
 
Learners Don't Color Within the Lines
Learners Don't Color Within the LinesLearners Don't Color Within the Lines
Learners Don't Color Within the LinesSean Bengry
 
Deloitte IWD Toolkit
Deloitte IWD ToolkitDeloitte IWD Toolkit
Deloitte IWD Toolkitjhaymeewilson
 
Public Relations, Advertising, Corp Comm &amp; Mar Com 1 F
Public Relations, Advertising, Corp Comm &amp; Mar Com  1 FPublic Relations, Advertising, Corp Comm &amp; Mar Com  1 F
Public Relations, Advertising, Corp Comm &amp; Mar Com 1 Fshahjipr
 
Presentacion suturas
Presentacion suturasPresentacion suturas
Presentacion suturasDrFher82
 
Advancing Manufacturing – Advancing Europe
Advancing Manufacturing – Advancing EuropeAdvancing Manufacturing – Advancing Europe
Advancing Manufacturing – Advancing EuropeCristóbal TeBe
 
Fighting Food Loss and Food Waste in Japan
Fighting Food Loss and Food Waste in JapanFighting Food Loss and Food Waste in Japan
Fighting Food Loss and Food Waste in JapanFAO
 
Manual de Personalización y Configuración de un Sistema Operativo (W-XP) (Un ...
Manual de Personalización y Configuración de un Sistema Operativo (W-XP) (Un ...Manual de Personalización y Configuración de un Sistema Operativo (W-XP) (Un ...
Manual de Personalización y Configuración de un Sistema Operativo (W-XP) (Un ...Ing-D-SW-TorresKhano--ME
 
Recycling vocabulary in the advanced eap reading class by Eliana Lili
Recycling vocabulary in the advanced eap reading class by Eliana Lili Recycling vocabulary in the advanced eap reading class by Eliana Lili
Recycling vocabulary in the advanced eap reading class by Eliana Lili TESOL Greece
 
Formato de planeacion por competencias
Formato de planeacion por competenciasFormato de planeacion por competencias
Formato de planeacion por competenciasAzul Olalde
 
Bloque 3 sugerencias didacticas 2
Bloque 3 sugerencias didacticas 2Bloque 3 sugerencias didacticas 2
Bloque 3 sugerencias didacticas 2alo_jl
 
Protein Synthesis Bowser
Protein Synthesis BowserProtein Synthesis Bowser
Protein Synthesis Bowserpunxsyscience
 
Indentured servants or slaves
Indentured servants or slavesIndentured servants or slaves
Indentured servants or slavesrlinde
 
Bloque 3 sugerencias didacticas 4
Bloque 3 sugerencias didacticas 4Bloque 3 sugerencias didacticas 4
Bloque 3 sugerencias didacticas 4alo_jl
 
Tiempos quirurgicos
Tiempos quirurgicosTiempos quirurgicos
Tiempos quirurgicosbeliaanais
 
(2012-10-25)Principios basicos de la sutura manual(doc)
(2012-10-25)Principios basicos de la sutura manual(doc)(2012-10-25)Principios basicos de la sutura manual(doc)
(2012-10-25)Principios basicos de la sutura manual(doc)UDMAFyC SECTOR ZARAGOZA II
 

Destaque (20)

Slavery in the colonies
Slavery in the coloniesSlavery in the colonies
Slavery in the colonies
 
Diseño
 Diseño Diseño
Diseño
 
Philosophical Issues and Ideas
Philosophical Issues and IdeasPhilosophical Issues and Ideas
Philosophical Issues and Ideas
 
Learners Don't Color Within the Lines
Learners Don't Color Within the LinesLearners Don't Color Within the Lines
Learners Don't Color Within the Lines
 
Ppt
PptPpt
Ppt
 
Deloitte IWD Toolkit
Deloitte IWD ToolkitDeloitte IWD Toolkit
Deloitte IWD Toolkit
 
Public Relations, Advertising, Corp Comm &amp; Mar Com 1 F
Public Relations, Advertising, Corp Comm &amp; Mar Com  1 FPublic Relations, Advertising, Corp Comm &amp; Mar Com  1 F
Public Relations, Advertising, Corp Comm &amp; Mar Com 1 F
 
Presentacion suturas
Presentacion suturasPresentacion suturas
Presentacion suturas
 
Advancing Manufacturing – Advancing Europe
Advancing Manufacturing – Advancing EuropeAdvancing Manufacturing – Advancing Europe
Advancing Manufacturing – Advancing Europe
 
Fighting Food Loss and Food Waste in Japan
Fighting Food Loss and Food Waste in JapanFighting Food Loss and Food Waste in Japan
Fighting Food Loss and Food Waste in Japan
 
Manual de Personalización y Configuración de un Sistema Operativo (W-XP) (Un ...
Manual de Personalización y Configuración de un Sistema Operativo (W-XP) (Un ...Manual de Personalización y Configuración de un Sistema Operativo (W-XP) (Un ...
Manual de Personalización y Configuración de un Sistema Operativo (W-XP) (Un ...
 
States of Liquid Matter
States of Liquid MatterStates of Liquid Matter
States of Liquid Matter
 
Recycling vocabulary in the advanced eap reading class by Eliana Lili
Recycling vocabulary in the advanced eap reading class by Eliana Lili Recycling vocabulary in the advanced eap reading class by Eliana Lili
Recycling vocabulary in the advanced eap reading class by Eliana Lili
 
Formato de planeacion por competencias
Formato de planeacion por competenciasFormato de planeacion por competencias
Formato de planeacion por competencias
 
Bloque 3 sugerencias didacticas 2
Bloque 3 sugerencias didacticas 2Bloque 3 sugerencias didacticas 2
Bloque 3 sugerencias didacticas 2
 
Protein Synthesis Bowser
Protein Synthesis BowserProtein Synthesis Bowser
Protein Synthesis Bowser
 
Indentured servants or slaves
Indentured servants or slavesIndentured servants or slaves
Indentured servants or slaves
 
Bloque 3 sugerencias didacticas 4
Bloque 3 sugerencias didacticas 4Bloque 3 sugerencias didacticas 4
Bloque 3 sugerencias didacticas 4
 
Tiempos quirurgicos
Tiempos quirurgicosTiempos quirurgicos
Tiempos quirurgicos
 
(2012-10-25)Principios basicos de la sutura manual(doc)
(2012-10-25)Principios basicos de la sutura manual(doc)(2012-10-25)Principios basicos de la sutura manual(doc)
(2012-10-25)Principios basicos de la sutura manual(doc)
 

Semelhante a 4 control statement

การเขียนฟังก์ชั่นในภาษา C
การเขียนฟังก์ชั่นในภาษา Cการเขียนฟังก์ชั่นในภาษา C
การเขียนฟังก์ชั่นในภาษา CWarawut
 
KMUTNB - Internet Programming 7/7
KMUTNB - Internet Programming 7/7KMUTNB - Internet Programming 7/7
KMUTNB - Internet Programming 7/7phuphax
 
3.ประเภทของข้อมูลและตัวดำเนินการ
3.ประเภทของข้อมูลและตัวดำเนินการ3.ประเภทของข้อมูลและตัวดำเนินการ
3.ประเภทของข้อมูลและตัวดำเนินการmansuang1978
 
เทคนิคการสืบค้นบนGoogle
เทคนิคการสืบค้นบนGoogleเทคนิคการสืบค้นบนGoogle
เทคนิคการสืบค้นบนGooglekikkok
 
เทคนิคการสืบค้นบนGoogle
เทคนิคการสืบค้นบนGoogleเทคนิคการสืบค้นบนGoogle
เทคนิคการสืบค้นบนGooglekikkok
 
Computer programming
Computer programmingComputer programming
Computer programmingJariyaa
 

Semelhante a 4 control statement (20)

1 test
1  test1  test
1 test
 
05 Loops
05  Loops05  Loops
05 Loops
 
Chapter 05 Loop
Chapter 05 LoopChapter 05 Loop
Chapter 05 Loop
 
Chapter 05 Loop
Chapter 05 LoopChapter 05 Loop
Chapter 05 Loop
 
C lang
C langC lang
C lang
 
การเขียนฟังก์ชั่นในภาษา C
การเขียนฟังก์ชั่นในภาษา Cการเขียนฟังก์ชั่นในภาษา C
การเขียนฟังก์ชั่นในภาษา C
 
3.8 การทำงานตามลำดับ
3.8 การทำงานตามลำดับ3.8 การทำงานตามลำดับ
3.8 การทำงานตามลำดับ
 
KMUTNB - Internet Programming 7/7
KMUTNB - Internet Programming 7/7KMUTNB - Internet Programming 7/7
KMUTNB - Internet Programming 7/7
 
3.ประเภทของข้อมูลและตัวดำเนินการ
3.ประเภทของข้อมูลและตัวดำเนินการ3.ประเภทของข้อมูลและตัวดำเนินการ
3.ประเภทของข้อมูลและตัวดำเนินการ
 
เทคนิคการสืบค้นบนGoogle
เทคนิคการสืบค้นบนGoogleเทคนิคการสืบค้นบนGoogle
เทคนิคการสืบค้นบนGoogle
 
เทคนิคการสืบค้นบนGoogle
เทคนิคการสืบค้นบนGoogleเทคนิคการสืบค้นบนGoogle
เทคนิคการสืบค้นบนGoogle
 
Array 2
Array 2Array 2
Array 2
 
Midterm
MidtermMidterm
Midterm
 
Computer programming
Computer programmingComputer programming
Computer programming
 
05 loops
05 loops05 loops
05 loops
 
power point.
power point.power point.
power point.
 
C language
C languageC language
C language
 
C language
C languageC language
C language
 
Computer Programming 3
Computer Programming 3 Computer Programming 3
Computer Programming 3
 
ตัวอย่างโปรแกรมลงBlog
ตัวอย่างโปรแกรมลงBlogตัวอย่างโปรแกรมลงBlog
ตัวอย่างโปรแกรมลงBlog
 

4 control statement

  • 1.  
  • 2.
  • 3.
  • 4.
  • 5. if statement Statement 1 expression Statement 2 false true expression Statement 3 true Statement 2 false Statement 1 แบบที่ 1 แบบที่ 2
  • 6.
  • 7.
  • 8. MAX = MIN = 1 ถ้ามีตัวเลขไม่ซ้ำค่าติดบนลูกบอล 5 ลูก ให้หาเลขที่น้อยที่สุดและมาก ที่สุดที่ติดบนฟุตบอล จะทำอย่างไร !!!
  • 9. MAX = MIN = 2 ถ้ามีตัวเลขไม่ซ้ำค่าติดบนลูกบอล 5 ลูก ให้หาเลขที่น้อยที่สุดและมาก ที่สุดที่ติดบนฟุตบอล จะทำอย่างไร !!!
  • 10. MAX = MIN = 3 ถ้ามีตัวเลขไม่ซ้ำค่าติดบนลูกบอล 5 ลูก ให้หาเลขที่น้อยที่สุดและมาก ที่สุดที่ติดบนฟุตบอล จะทำอย่างไร !!!
  • 11. MAX = MIN = 4 ถ้ามีตัวเลขไม่ซ้ำค่าติดบนลูกบอล 5 ลูก ให้หาเลขที่น้อยที่สุดและมาก ที่สุดที่ติดบนฟุตบอล จะทำอย่างไร !!!
  • 12. MAX = MIN = 5 ถ้ามีตัวเลขไม่ซ้ำค่าติดบนลูกบอล 5 ลูก ให้หาเลขที่น้อยที่สุดและมาก ที่สุดที่ติดบนฟุตบอล จะทำอย่างไร !!!
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. เขียนคำสั่ง For statement แสดงผลดังนี้
  • 20.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.

Notas do Editor

  1. Break = j=10 , k=1, l=0 No break j=4 , k=7, l=6