Cpwk14 screen and soundKnow MastikateThe 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.
การใช้ Turbo C ชุดที่ 11 functionKnow MastikateThe 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.
Cpwk14 screen and soundKnow MastikateThe 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.
การใช้ Turbo C ชุดที่ 11 functionKnow MastikateThe 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.
การใช้ Turbo C ชุดที่ 10 PointerKnow MastikateThe 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.
เอกสาร Program C for Pc-DigitalKnow MastikateProgram C for Pc-Digital
นาย วีรชน ต๊ะเรือน
คณะวิชา ไฟฟ้า สาขาวิชา ครุศาสตร์อุตสาหกรรม และ อิเล็กทรอนิกส์
มหาวิทยาลัย เทคโนโลยีราชมงคลลานนา วิทยาเขตพายัพ
8. Copyright (c) 2006 by Sasalak Tongkaw8
COMPUTER PROGRAMMING AND ALGORITH
ตัวอย่าง ผังงานปกติ
EOFEOF
Print “END”Print “END”
Print ANSPrint ANS
StartStart
Yes
ANS=number*2ANS=number*2
EndEnd
No
Get numberGet number
Get numberGet numberNumber=0Number=0
แยกเป็นโปรแกรมย่อยชื่อ
Double_it
9. Copyright (c) 2006 by Sasalak Tongkaw9
COMPUTER PROGRAMMING AND ALGORITH
โปรแกรม Double1.cpp
#include<stdio.h>
#include<conio.h>
void main()
{
int number,ans;
clrscr();
printf("Number=");
scanf("%d",&number);
do {
ans=number*2; //แยกไปเป็นโปรแกรมย่อย
Double_it
printf("ANS=%dn",ans);
printf("Number=");
scanf("%d",&number);
} while (number!=0);
}
10. Copyright (c) 2006 by Sasalak Tongkaw10
COMPUTER PROGRAMMING AND ALGORITH
ตัวอย่าง ผังงานมีโปรแกรมย่อย
Double_It
EOFEOF
Print “END”Print “END”
Print ANSPrint ANS
StartStart
Yes
EndEnd
No
Get numberGet number
Get numberGet number
Double_itDouble_it
Double_ItDouble_It
Double_itDouble_it
ReturnReturn
Number=0Number=0
11. Copyright (c) 2006 by Sasalak Tongkaw11
COMPUTER PROGRAMMING AND ALGORITH
โปรแกรม Double2.cpp
#include<stdio.h>
#include<conio.h>
int number,ans;
void double_it()
{
ans=number*2;
}
void main()
{ clrscr();
printf("Number=");
scanf("%d",&number);
do {
double_it();
printf("ANS=%dn",ans);
printf("Number=");
scanf("%d",&number);
} while (number!=0);
}
12. Copyright (c) 2006 by Sasalak Tongkaw12
COMPUTER PROGRAMMING AND ALGORITH
ตัวแปรที่ใช้งานในโปรแกรม
• ตัวแปรแบบโกลบอล global variable
• ตัวแปรแบบโลคอล local variable
13. Copyright (c) 2006 by Sasalak Tongkaw13
COMPUTER PROGRAMMING AND ALGORITH
ตัวแปรแบบโกลบอล Global
Variable
• เป็นตัวแปรที่ใช้ตลอดทั้ง
โปรแกรม ทั้งในโปรแกรมหลัก
และในโปรแกรมย่อย
• ประกาศไว้ภายนอกโปรแกรม
หลักเพียงครั้งเดียว
14. Copyright (c) 2006 by Sasalak Tongkaw14
COMPUTER PROGRAMMING AND ALGORITH
Global Variable
#include<stdio.h>
#include<conio.h>
int number,ans;
Function 1
Function 2
Main program
15. Copyright (c) 2006 by Sasalak Tongkaw15
COMPUTER PROGRAMMING AND ALGORITH
โปรแกรม Double2.cpp
#include<stdio.h>
#include<conio.h>
int number,ans;
void doubleit()
{
ans=number*2;
}
void main()
{ clrscr();
printf("Number=");
scanf("%d",&number);
do {
doubleit();
printf("ANS=%dn",ans);
printf("Number=");
scanf("%d",&number);
} while (number!=0);
}
Global variable
Function
Main Program
16. Copyright (c) 2006 by Sasalak Tongkaw16
COMPUTER PROGRAMMING AND ALGORITH
ตัวแปรแบบโลคอล Local Variable
• ตัวแปรที่ใช้ในโพรซีเจอร์หรือ
ฟังก์ชัน
• การเปลี่ยนแปลงค่าของตัวแปรโล
คอลจะไม่กระทบต่อโปรแกรม
หลักข้างนอก
17. Copyright (c) 2006 by Sasalak Tongkaw17
COMPUTER PROGRAMMING AND ALGORITH
โปรแกรม Double1.cpp
#include<stdio.h>
#include<conio.h>
void main()
{
int number,ans;
clrscr();
printf("Number=");
scanf("%d",&number);
do {
ans=number*2;
printf("ANS=%dn",ans);
printf("Number=");
scanf("%d",&number);
} while (number!=0);
}
Local Variable
19. Copyright (c) 2006 by Sasalak Tongkaw19
COMPUTER PROGRAMMING AND ALGORITH
โปรแกรมโปรแกรม EasyFunc1.cppEasyFunc1.cpp
#include<stdio.h>
void main()
{
printf(“Beginn”);
printf(“==== MENU ====nn”);
printf(“a) Say Hellon”);
printf(“b) Say Good Byen”);
printf(“Select a or b : n”);
printf(“ENDn”);
}
#include<stdio.h>
void main()
{
printf(“Beginn”);
printf(“==== MENU ====nn”);
printf(“a) Say Hellon”);
printf(“b) Say Good Byen”);
printf(“Select a or b : n”);
printf(“ENDn”);
}
Begin
==== MENU ====
a) Say Hello
b) Say Good Bye
Select a or b :
END
Begin
==== MENU ====
a) Say Hello
b) Say Good Bye
Select a or b :
END
จงเขียนฟังก์ชัน showmenu();
20. Copyright (c) 2006 by Sasalak Tongkaw20
COMPUTER PROGRAMMING AND ALGORITH
เฉลย โปรแกรมเฉลย โปรแกรม EasyFunc2.cppEasyFunc2.cpp
#include<stdio.h>
void showmenu()
{
printf(“==== MENU ====nn”);
printf(“a) Say Hellon”);
printf(“b) Say Good Byen”);
printf(“Select a or b : n”);
}
Void main()
{
printf(“Beginn”);
showmenu();
printf(“ENDn”);
}
#include<stdio.h>
void showmenu()
{
printf(“==== MENU ====nn”);
printf(“a) Say Hellon”);
printf(“b) Say Good Byen”);
printf(“Select a or b : n”);
}
Void main()
{
printf(“Beginn”);
showmenu();
printf(“ENDn”);
}
Begin
==== MENU ====
a) Say Hello
b) Say Good Bye
Select a or b :
END
Begin
==== MENU ====
a) Say Hello
b) Say Good Bye
Select a or b :
END
2
1
3
4
5
6
7
8
9
10
21. Copyright (c) 2006 by Sasalak Tongkaw21
COMPUTER PROGRAMMING AND ALGORITH
โปรแกรมย่อยของโปรแกรมย่อย
เป็นโปรแกรมย่อยที่อยู่ภายใน
โปรแกรมย่อยอีกทีหนึ่ง
22. Copyright (c) 2006 by Sasalak Tongkaw22
COMPUTER PROGRAMMING AND ALGORITH
ผังลำาดับขั้นผังลำาดับขั้น Hierarchy chartHierarchy chart
Main
Compute-BillGet-Order Print-Bill
Compute-
Tax
Compute-
Discount