SlideShare a Scribd company logo
ภาษาซี
ประวัติภาษาซี
การเริ่มต้นพัฒนาภาษาซีเกิดขึ้นที่เบลล์แล็บส์ของเอทีแอนด์ที
ระหว่าง พ.ศ. 2512–2516 แต่ตามข้อมูลของริตชี ช่วงเวลาที่เกิดความ
สร้างสรรค์มากที่สุดคือ พ.ศ. 2515 ภาษานี้ถูกตั้งชื่อว่า "ซี" เพราะ
คุณลักษณะต่าง ๆ ต่อยอดมาจากภาษาก่อนหน้าคือ "บี" ซึ่งจากข้อมูลของ
เคน ทอมป์สัน (Ken Thompson) กล่าวว่าภาษาบีเป็นรุ่นที่แยกตัวออกจาก
ภาษาบีซีพีแอลอีกทอดหนึ่ง
จนมาถึง พ.ศ.2526 Bjarne Stroustrup แห่งห้องปฏิบัติการเบล
(Bell Laboratories) ได้พัฒนาภาษา C++ ขึ้นรายละเอียดและความสามารถ
ของ C++ มีส่วนขยายเพิ่มจาก C ที่สาคัญ ๆ ได้แก่ แนวความคิดของการ
เขียนโปรแกรมแบบกาหนดวัตถุเป้าหมายหรือแบบ OOP (Object Oriented
Programming) ซึ่งเป็นแนวการเขียนโปรแกรมที่เหมาะกับการพัฒนา
โปรแกรมขนาดใหญ่ที่มีความสลับซับซ้อนมาก มีข้อมูลที่ใช้ในโปรแกรม
จานวนมาก จึงนิยมใช้เทคนิคของการเขียนโปรแกรมแบบ OOP ในการ
พัฒนาโปรแกรมขนาดใหญ่ในปัจจุบันนี้
ชนิดของข้อมูล ประกอบไปด้วย
1. character (char) ใช้1 byte บน Dos มีค่า -128 ถึง127 นิยม
ใช้เก็บตัวอักษร 1 ตัวอักษร
2. integer (int) ใช้ 2 byte มีค่า -32768 ถึง 32767 และยังมี long
ซึ่งคล้าย integer แต่เก็บด้วย ช่วงตัวเลขที่ยาวกว่าจึงกินเนื้อที่ ถึง 4 byte
3. float ใช้ 2 byte ใช้เก็บตัวเลขทศนิยม และยังมี double ซึ่ง
คล้าย float แต่เก็บด้วยช่วงตัวเลขที่ยาวกว่าจึงกินเนื้อที่ถึง 4 byte
4. ในภาษา C จะไม่มีชนิดข้อมูลเป็น string แต่จะใช้สายของ
อักษร หรือ Array ของ Char แทนความจริงแล้ว ชนิดของข้อมูลยังสามารถ
จาแนกไปได้อีกมาก แต่ในที่นี้ขอแนะนาเพียงเท่านี้ก่อน ก็เพียงพอ
โครงสร้างของภาษาซี
ทุกโปรแกรมของภาษา C มีโครงสร้างเป็นลักษณะ
ดังรูป
เฮดเดอร์ไฟล์ (Header Files)เป็นส่วนที่เก็บไลบรารี่
มาตรฐานของภาษา C ซึ่งจะถูกดึงเข้ามารวมกับโปรแกรมในขณะที่
กาลังทาการคอมไพล์
ข้อดีของภาษาซี
- เป็นภาษาคอมพิวเตอร์ที่มีการพัฒนาขึ้นใช้งานเพื่อเป็นภาษา
มาตรฐานที่ไม่ขึ้นกับโปรแกรมจัดระบบงานและไม่ขึ้นกับฮาร์ดแวร์
- เป็นภาษาคอมพิวเตอร์ที่อาศัยหลักการที่เรียกว่า "โปรแกรม
โครงสร้าง" จึงเป็นภาษาที่เหมาะกับการพัฒนาโปรแกรมระบบ
- เป็นคอมไพเลอร์ที่มีประสิทธิภาพสูง ให้รหัสออบเจ็กต์สั้น
ทางานได้รวดเร็ว เหมาะกับงานที่ต้องการ ความรวดเร็วเป็นสาคัญ
- มีความคล่องตัวคล้ายภาษาแอสแซมบลี ภาษาซีสามารถเขียน
แทนภาษาแอสแซมบลีได้ดี ค้นหาที่ผิดหรือ แก้โปรแกรมได้ง่าย ภาษาซีจึง
เป็นภาษาระดับสูงที่ทางานเหมือนภาษาระดับต่า
- มีความคล่องตัวที่จะประยุกต์เข้ากับงานต่างๆ ได้เป็นอย่างดี
การพัฒนาโปรแกรม เช่น เวิร์ดโพรเซสซิ่ง สเปรดชีต ดาตาเบส ฯลฯ มักใช้
ภาษาซีเป็นภาษาสาหรับการพัฒนา
- เป็นภาษาที่มีอยู่บนเกือบทุกโปรแกรมจัดระบบงาน มีในเครื่อง
ไมโครคอมพิวเตอร์ตั้งแต่ 8 บิต ไปจนถึง 32 บิต เครื่องมินิคอมพิวเตอร์ และ
เมนเฟรม
ข้อเสียของภาษาซี
- เป็นภาษาที่เรียนรู้ยาก
- การตรวจสอบโปรแกรมทาได้ยาก
- ไม่เหมาะกับการเขียนโปรแกรมที่เกี่ยวข้องกับการออกรายงาน
ที่มีรูปแบบซับซ้อนมากๆ
ตัวอย่างการเขียนโฟชาร์ทของภาษซี
โจทย์ : C จงเขียนโปรแกรมรับ เลขจานวนเต็ม 1 ตัวแล้ว
ตรวจสอบว่าเป็นเลขคู่ (Even) หรือ เลขคี่ (Odd)
วิเคราะห์โจทย์ จากโจทย์แบ่งออกเป็นส่วน การรับค่า
จานวนเต็ม และการตรวจสอบเลขคู่ เลขคี่ ซึ่งวิธีการตรวจสอบจะ
ใช้เงื่อนไขคือ ตัวแปรที่เก็บตัวเลข mod (หารเอาเศษ) ด้วย 2 ผลจาก
การคานวณ ถ้าได้ 0 คือเลขคู่ นอกนั้นคือเลขคี่
ผังโฟชาร์ท มีดังนี้...
จัดทาโดย
นางสาวธิดารัตน์ รอดกูล เลขที่ 27
นางสาวสวลี คงยืน เลขที่ 28
ชั้นมัธยมศึกษาปีที่ 5/1
โรงเรียนรัษฎานุประดิษฐ์อนุสรณ์
ภาษาซี

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

แผ่นพับภาษาซี

  • 1. ภาษาซี ประวัติภาษาซี การเริ่มต้นพัฒนาภาษาซีเกิดขึ้นที่เบลล์แล็บส์ของเอทีแอนด์ที ระหว่าง พ.ศ. 2512–2516 แต่ตามข้อมูลของริตชี ช่วงเวลาที่เกิดความ สร้างสรรค์มากที่สุดคือ พ.ศ. 2515 ภาษานี้ถูกตั้งชื่อว่า "ซี" เพราะ คุณลักษณะต่าง ๆ ต่อยอดมาจากภาษาก่อนหน้าคือ "บี" ซึ่งจากข้อมูลของ เคน ทอมป์สัน (Ken Thompson) กล่าวว่าภาษาบีเป็นรุ่นที่แยกตัวออกจาก ภาษาบีซีพีแอลอีกทอดหนึ่ง จนมาถึง พ.ศ.2526 Bjarne Stroustrup แห่งห้องปฏิบัติการเบล (Bell Laboratories) ได้พัฒนาภาษา C++ ขึ้นรายละเอียดและความสามารถ ของ C++ มีส่วนขยายเพิ่มจาก C ที่สาคัญ ๆ ได้แก่ แนวความคิดของการ เขียนโปรแกรมแบบกาหนดวัตถุเป้าหมายหรือแบบ OOP (Object Oriented Programming) ซึ่งเป็นแนวการเขียนโปรแกรมที่เหมาะกับการพัฒนา โปรแกรมขนาดใหญ่ที่มีความสลับซับซ้อนมาก มีข้อมูลที่ใช้ในโปรแกรม จานวนมาก จึงนิยมใช้เทคนิคของการเขียนโปรแกรมแบบ OOP ในการ พัฒนาโปรแกรมขนาดใหญ่ในปัจจุบันนี้ ชนิดของข้อมูล ประกอบไปด้วย 1. character (char) ใช้1 byte บน Dos มีค่า -128 ถึง127 นิยม ใช้เก็บตัวอักษร 1 ตัวอักษร 2. integer (int) ใช้ 2 byte มีค่า -32768 ถึง 32767 และยังมี long ซึ่งคล้าย integer แต่เก็บด้วย ช่วงตัวเลขที่ยาวกว่าจึงกินเนื้อที่ ถึง 4 byte 3. float ใช้ 2 byte ใช้เก็บตัวเลขทศนิยม และยังมี double ซึ่ง คล้าย float แต่เก็บด้วยช่วงตัวเลขที่ยาวกว่าจึงกินเนื้อที่ถึง 4 byte 4. ในภาษา C จะไม่มีชนิดข้อมูลเป็น string แต่จะใช้สายของ อักษร หรือ Array ของ Char แทนความจริงแล้ว ชนิดของข้อมูลยังสามารถ จาแนกไปได้อีกมาก แต่ในที่นี้ขอแนะนาเพียงเท่านี้ก่อน ก็เพียงพอ โครงสร้างของภาษาซี ทุกโปรแกรมของภาษา C มีโครงสร้างเป็นลักษณะ ดังรูป เฮดเดอร์ไฟล์ (Header Files)เป็นส่วนที่เก็บไลบรารี่ มาตรฐานของภาษา C ซึ่งจะถูกดึงเข้ามารวมกับโปรแกรมในขณะที่ กาลังทาการคอมไพล์ ข้อดีของภาษาซี - เป็นภาษาคอมพิวเตอร์ที่มีการพัฒนาขึ้นใช้งานเพื่อเป็นภาษา มาตรฐานที่ไม่ขึ้นกับโปรแกรมจัดระบบงานและไม่ขึ้นกับฮาร์ดแวร์ - เป็นภาษาคอมพิวเตอร์ที่อาศัยหลักการที่เรียกว่า "โปรแกรม โครงสร้าง" จึงเป็นภาษาที่เหมาะกับการพัฒนาโปรแกรมระบบ - เป็นคอมไพเลอร์ที่มีประสิทธิภาพสูง ให้รหัสออบเจ็กต์สั้น ทางานได้รวดเร็ว เหมาะกับงานที่ต้องการ ความรวดเร็วเป็นสาคัญ - มีความคล่องตัวคล้ายภาษาแอสแซมบลี ภาษาซีสามารถเขียน แทนภาษาแอสแซมบลีได้ดี ค้นหาที่ผิดหรือ แก้โปรแกรมได้ง่าย ภาษาซีจึง เป็นภาษาระดับสูงที่ทางานเหมือนภาษาระดับต่า - มีความคล่องตัวที่จะประยุกต์เข้ากับงานต่างๆ ได้เป็นอย่างดี การพัฒนาโปรแกรม เช่น เวิร์ดโพรเซสซิ่ง สเปรดชีต ดาตาเบส ฯลฯ มักใช้ ภาษาซีเป็นภาษาสาหรับการพัฒนา - เป็นภาษาที่มีอยู่บนเกือบทุกโปรแกรมจัดระบบงาน มีในเครื่อง ไมโครคอมพิวเตอร์ตั้งแต่ 8 บิต ไปจนถึง 32 บิต เครื่องมินิคอมพิวเตอร์ และ เมนเฟรม ข้อเสียของภาษาซี - เป็นภาษาที่เรียนรู้ยาก - การตรวจสอบโปรแกรมทาได้ยาก - ไม่เหมาะกับการเขียนโปรแกรมที่เกี่ยวข้องกับการออกรายงาน ที่มีรูปแบบซับซ้อนมากๆ
  • 2. ตัวอย่างการเขียนโฟชาร์ทของภาษซี โจทย์ : C จงเขียนโปรแกรมรับ เลขจานวนเต็ม 1 ตัวแล้ว ตรวจสอบว่าเป็นเลขคู่ (Even) หรือ เลขคี่ (Odd) วิเคราะห์โจทย์ จากโจทย์แบ่งออกเป็นส่วน การรับค่า จานวนเต็ม และการตรวจสอบเลขคู่ เลขคี่ ซึ่งวิธีการตรวจสอบจะ ใช้เงื่อนไขคือ ตัวแปรที่เก็บตัวเลข mod (หารเอาเศษ) ด้วย 2 ผลจาก การคานวณ ถ้าได้ 0 คือเลขคู่ นอกนั้นคือเลขคี่ ผังโฟชาร์ท มีดังนี้... จัดทาโดย นางสาวธิดารัตน์ รอดกูล เลขที่ 27 นางสาวสวลี คงยืน เลขที่ 28 ชั้นมัธยมศึกษาปีที่ 5/1 โรงเรียนรัษฎานุประดิษฐ์อนุสรณ์ ภาษาซี