1 / 27

886201 หลักการ โปรแกรม 1

886201 หลักการ โปรแกรม 1. Lecture 1: ความรู้เบื้องต้นเกี่ยวกับการโปรแกรม. โปรแกรม.

Download Presentation

886201 หลักการ โปรแกรม 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 886201 หลักการโปรแกรม 1 Lecture 1: ความรู้เบื้องต้นเกี่ยวกับการโปรแกรม

  2. โปรแกรม • โปรแกรมคือ รูปแบบทางตรรกะของคำสั่งต่างๆ ที่นำมารวมกันเพื่อแก้ปัญหาเฉพาะบางอย่าง และนำมาใช้สั่งให้คอมพิวเตอร์ทำงาน ผู้เขียนโปรแกรมจะเขียนโปรแกรมตามความต้องการของนักวิเคราะห์ระบบ หรืออาจกล่าวได้สั้นๆ ว่า โปรแกรมหมายถึง ชุดคำสั่งซึ่งถูกเขียนขึ้นเพื่อสั่งให้คอมพิวเตอร์ทำงานตามต้องการ The Electronic Numerical Integrator And Computer (The ENIAC)

  3. ตัวแปลภาษา

  4. Edit-Compile-Run กระบวนการพัฒนาโปรแกรมที่โปรแกรมเมอร์ทุกคนต้องทำ (เหมือนเป็นวงจรชีวิต) ก็คือ การเขียน/แก้ไข โปรแกรม การคอมไพล์ และการรันโปรแกรม

  5. ภาษา C++ • C (1972) • ANSI Standard C (1989) • C++ (1985) BjarneStroustrup • ANSI Standard C++ (1998) • ANSI Standard C++ [revised] (2003)

  6. IDE - CodeBlocks

  7. เริ่มต้นเขียนโปรแกรม 1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 cout << "Hello, World!" << endl; 8 return 0; 9 }

  8. เริ่มต้นเขียนโปรแกรม

  9. ข้อผิดพลาดที่มักพบบ่อยข้อผิดพลาดที่มักพบบ่อย Oh No! 1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 cout << "Hello, World!" << endl 8 return 0; 9 }

  10. ข้อผิดพลาดที่มักพบบ่อยข้อผิดพลาดที่มักพบบ่อย Oh No! 1 #include <iostream> 2 3 using namespace std; 4 5 intMain() 6 { 7 cout << "Hello, World!" << endl; 8 return 0; 9 }

  11. ข้อผิดพลาดที่มักพบบ่อยข้อผิดพลาดที่มักพบบ่อย Oh No! 1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 cout << "Hello, World!" << end1; 8 return 0; 9 } ใช้ตัว ‘แอล’ ไม่ใช่ เลขหนึ่ง

  12. ข้อผิดพลาดที่มักพบบ่อยข้อผิดพลาดที่มักพบบ่อย Oh No! 1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 cout>> "Hello, World!" << end1; 8 return 0; 9 } ใช้เครื่องหมาย << ไม่ใช่ >>

  13. การเขียนโปรแกรมให้อ่านง่ายการเขียนโปรแกรมให้อ่านง่าย นิสิตรู้สึกอย่างไรกับรูปแบบการเขียนโปรแกรมแบบนี้ ? intmain(){cout<<"Hello, World!"<<endl;return 0;}

  14. การเขียนโปรแกรมให้อ่านง่ายการเขียนโปรแกรมให้อ่านง่าย int main() { cout << "Hello, World!" << endl; return 0; }

  15. Learn by Example

  16. ตัวอย่างโปรแกรม 1 1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 cout<< "Hello, "; 8 cout << "World!" << endl; 9 return 0; 10} สังเกตุว่าไม่มีคำสั่ง endl

  17. ตัวอย่างโปรแกรม 2 1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 cout<< "Hello, " << endl; 8 cout << "World!" << endl; 9 return 0; 10} สังเกตุว่ามีคำสั่ง endl

  18. ตัวอย่างโปรแกรม 3 1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 cout<< "Test: "; 8 cout << "1 + 2" << endl; 9 return 0; 10} ลองสังเกตุเครื่องหมายคำพูด

  19. ตัวอย่างโปรแกรม 4 1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 cout<< "Test: "; 8 cout << 1 + 2 << endl; 9 return 0; 10} สังเกตุว่า ไม่มี เครื่องหมายคำพูด

  20. ตัวอย่างโปรแกรม 5 1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 cout<< " / \\" << endl; 8 cout<< " / \\" << endl; 9 cout<< " / \\" << endl; 10 cout << " -------" << endl; 11 return 0; 12} สังเกตุว่าใช้เครื่องหมาย ‘\’ 2 อัน

  21. แบบฝึกหัด

  22. โปรแกรมต่อไปนี้แสดงผลลัพธ์อะไรออกทางหน้าจอโปรแกรมต่อไปนี้แสดงผลลัพธ์อะไรออกทางหน้าจอ

  23. โปรแกรมต่อไปนี้แสดงผลลัพธ์อะไรออกทางหน้าจอโปรแกรมต่อไปนี้แสดงผลลัพธ์อะไรออกทางหน้าจอ

  24. โปรแกรมต่อไปนี้แสดงผลลัพธ์อะไรออกทางหน้าจอโปรแกรมต่อไปนี้แสดงผลลัพธ์อะไรออกทางหน้าจอ

  25. โปรแกรมต่อไปนี้ผิดพลาดตรงตำแหน่งใดโปรแกรมต่อไปนี้ผิดพลาดตรงตำแหน่งใด

  26. โปรแกรมต่อไปนี้ผิดพลาดตรงตำแหน่งใดโปรแกรมต่อไปนี้ผิดพลาดตรงตำแหน่งใด

  27. ลองเขียนโปรแกรมเพื่อพิมพ์รูปต่อไปนี้ออกทางหน้าจอลองเขียนโปรแกรมเพื่อพิมพ์รูปต่อไปนี้ออกทางหน้าจอ

More Related