The document contains information about computer programming functions in three sections:
1. It defines a function and explains the basic components of a function like the function name, parameters, return type, and return statement.
2. It describes different ways a function can be called - by value, by reference, and passing an array by reference. It provides code examples to illustrate each case.
3. It discusses global and local variables, and variable modifiers like static and extern that change how variables can be accessed within and outside functions.
The document contains information about computer programming functions in three sections:
1. It defines a function and explains the basic components of a function like the function name, parameters, return type, and return statement.
2. It describes different ways a function can be called - by value, by reference, and passing an array by reference. It provides code examples to illustrate each case.
3. It discusses global and local variables, and variable modifiers like static and extern that change how variables can be accessed within and outside functions.
The document provides an overview of computer programming concepts including:
1. Text mode and graphics mode for display.
2. Window functions for defining screen areas.
3. Text formatting functions for color, background, and positioning.
4. Sound functions for generating tones and stopping sound.
5. Graphics functions for shapes, lines, text and flood fill.
The document provides an introduction to computer programming pointers in 3 sections. Section 1 defines pointers and their uses to reference memory locations. Section 2 demonstrates how to use pointers to reference and modify variable values. Section 3 shows pointers being used to swap the values of two variables by passing their addresses to a function. The document concludes by thanking the reader.
The document provides an overview of computer programming concepts including:
1. Text mode and graphics mode for display.
2. Window functions for defining screen areas.
3. Text formatting functions for color, background, and positioning.
4. Sound functions for generating tones and stopping sound.
5. Graphics functions for shapes, lines, text and flood fill.
The document provides an introduction to computer programming pointers in 3 sections. Section 1 defines pointers and their uses to reference memory locations. Section 2 demonstrates how to use pointers to reference and modify variable values. Section 3 shows pointers being used to swap the values of two variables by passing their addresses to a function. The document concludes by thanking the reader.
9. Copyright (c) 2006 by Sasalak Tongkaw9
COMPUTER PROGRAMMING AND ALGORITH
โครงสร้างการตัดสินใจแบบทางเลือก
เดียว
• โครงสร้างการตัดสินใจแบบทาง
เลือกเดียว (single-alternative
decision) มีทางเลือกสำาหรับ
ตัดสินใจเพียงทางเดียวดังภาพ
Year=4 ?
Graduation
Routine
No Yes
Don’t Do
Anything
10. Copyright (c) 2006 by Sasalak Tongkaw10
COMPUTER PROGRAMMING AND ALGORITH
โปรแกรมภาษาซีที่มีทางเลือกเดียว
#include<stdio.h>
void main()
{
int age;
printf(“How old are you ”);
scanf(“%d”,&age);
if (age>=60)
printf(“You are oldn”);
printf(“Good Bye ! ”);
}
12. Copyright (c) 2006 by Sasalak Tongkaw12
COMPUTER PROGRAMMING AND ALGORITH
การเชื่อมต่อโดยการใช้ “และ”
• เป็นการตัดสินใจที่มีมากกว่า 1
เงื่อนไข เช่น
• ต้องการให้เงินค่าล่วงเวลาสำาหรับ
พนักงานที่ทำางานเกิน 40 ชั่วโมง
และเป็นพนักงานใน Class 1
• มี 2 เงื่อนไขคือ
– 1. ต้องทำางานเกิน 40 ชั่วโมง
– 2. ต้องเป็นพนักงานใน Class 1
13. Copyright (c) 2006 by Sasalak Tongkaw13
COMPUTER PROGRAMMING AND ALGORITH
ผังงานแสดงเงื่อนไขแบบ “และ”
Hour>40 ?
Class=1 ?
Overtime
Yes
Yes
No
No
Hour>40 ?
Class 1 ?
ข้อควรระวังในการสลับที่คือ
ประสิทธิภาพของการทำางาน
ข้อควรระวังในการสลับที่คือ
ประสิทธิภาพของการทำางาน
14. Copyright (c) 2006 by Sasalak Tongkaw14
COMPUTER PROGRAMMING AND ALGORITH
การเชื่อมต่อโดยการใช้ “หรือ”
• จะทำางานก็ต่อเมื่อเงื่อนไขหนึ่ง
เงื่อนไขใดเป็นจริงหรือเป็นจริงทั้ง
สองเงื่อนไขก็ได้ เช่น
• บริษัทจะให้โบนัสแก่พนักงานที่
เป็นพนักงานใน Class 1 หรือ
เป็นพนักงานใน Class 2
• โครงสร้างของผังงานแสดง
เงื่อนไขแบบ “หรือ”
15. Copyright (c) 2006 by Sasalak Tongkaw15
COMPUTER PROGRAMMING AND ALGORITH
โครงสร้างของผังงานที่มีเงื่อนไขแบบ
“หรือ”
Class =1?
Bonus
Yes
Yes
No
No
Class =2 ?
Bonus
ข้อควรระวังในการ
สลับที่คือ
ประสิทธิภาพของ
การทำางาน
เช่นเดียวกัน
ข้อควรระวังในการ
สลับที่คือ
ประสิทธิภาพของ
การทำางาน
เช่นเดียวกัน
16. Copyright (c) 2006 by Sasalak Tongkaw16
COMPUTER PROGRAMMING AND ALGORITH
การตัดสินใจโดยใช้ทั้งสองวิธีร่วมกัน
• สำาหรับภาษาซีสามารถจะใช้ทั้ง
สองวิธีที่กล่าวมาแล้วร่วมกันได้
• ใช้สัญลักษณ์ทางคณิตศาสตร์
ดังนี้
• && หมายถึง “และ” and
• || หมายถึง “หรือ” or
• ! หมายถึง “ไม่” not
17. Copyright (c) 2006 by Sasalak Tongkaw17
COMPUTER PROGRAMMING AND ALGORITH
ตัวอย่างผังงานการตัดสินใจแบบใช้
สองวิธีร่วมกัน
Hour>40
and Class
=1 ?
Overtime
YesNo Class =1 or
Class=2 ?
Bonus
YesNo