Page 85 - แผนจัดการเรียนรู้
P. 85

เฉลย                                           ใบงานที่ 2.3

                                     เรื่อง การเขียนโปรแกรมคอมพิวเตอร์จากอัลกอริทึม

               ตอนที่ 1 คำชี้แจง : จงเขียนโปรแกรมคอมพิวเตอร์ จากโจทย์ที่กำหนดให้ต่อไปนี้

               1. จงบอกส่วนประกอบหลักของโปรแกรม Scratch ของแต่ละหมายเลข


                                     #include<stdio.h>

                                    void main()
                                    {

                                           float radius, area, circum;
                                           printf("Please enter radius of cycle : ");

                                           scanf("%f", &radius);

                                           area = 3.14 * radius * radius;
                                           circum = 2 * 3.14 * radius;

                                           printf("Area of cycle : %.2f\n", area);
                                           printf("Circumference of cycle : %.2f", circum);

                                     }





                                                                                                    ิ
               2. จงเปลี่ยนอุณหภูมิจากองศาเซลเซียสเป็นฟาเรนไฮต์ โดยป้อนอุณหภูมิเป็นองศาเซลเซียส ทางแป้นพมพ์
                  แล้วแสดงผลลัพธ์ทางจอภาพ


                                 #include<stdio.h>
                                 main() {

                                       float celsius, fahrenheit;

                                       printf("Please enter Celsius degree : ");
                                       scanf("%f", &celsius);

                                       fahrenheit = ((9/5) * celsius) + 32;
                                       printf("%.2f C degree is equal %.2f F Degree\n", celsius, fahrenheit);

                                 }
   80   81   82   83   84   85   86   87   88   89   90