01006012 Computer Programming 4 1 01006012 Computer Programming
- Slides: 64
01006012 Computer Programming ����� 4 ���������������������������� 1 01006012 Computer Programming
01006012 Computer Programming Problem Algorithms Representation 6
Origami 01006012 Computer Programming 8
ตวอยางผงงานโปรแกรม 01006012 Computer Programming #include<stdio. h> int main() { printf ("Hello World!"); 21
แนวทางสรางโปรแกรมคำนวณหาพนทวงกลม (3) 01006012 Computer Programming float radius, pi, area; pi=22. 0/7; // pi = 3. 14; printf ("Enter Radius of Circular : "); scanf ("%f", &radius); area = pi * radius; printf ("Area of Circular : %f", area); 25
แนวทางสรางโปรแกรมคำนวณหาพนทวงกลม (4) 01006012 Computer Programming #include<stdio. h> int main() { float radius, pi, area; pi = 22. 0/7; // pi = 3. 14; printf ("Enter Radius of Circular : "); scanf ("%f", &radius); area = pi * radius; printf ("Area of Circular : %f", area); return 0; } 26
การใชงานเครองหมายทางตรรกศาสตร (2) 01006012 Computer Programming int num 1 = 10, num 2 = 20, num 3 = 30; num 1 == num 2 False num 1 > num 2 False (num 1<num 2) && (num 2<num 3) True (num 1>num 2) || (num 1>num 3) False (num 1>num 2) || (num 2<num 3) True 33
4. 3 การใชคำสง if 01006012 Computer Programming if (expression) statement; if (expression) { statement-1. 1; statement-1. 2; . . . statement-1. n; } 34
การใชคำสง if กบนพจน int a = ; int b = ; if (a>b) { statement 1; statement 2; statement n; } printf(); 01006012 Computer Programming a = b = ; ; a > b False True statement 1; statement 2; statement 3; 35
โปรแกรมตรวจสอบคะแนน START first, last, id, point, full first, last, id | if (4) 1 point/full>=0. 6 False True "passed" point, full 1 END 39
โปรแกรมตรวจสอบคะแนน | if (5) 01006012 Computer Programming #include<stdio. h> int main() { char first[20], last[20], id[9]; float point, full; printf scanf ("Enter your Name : "); ("%s", first); ("Enter your Surname : "); ("%s", last); ("Enter your ID : "); ("%s", id); 40
โปรแกรมตรวจสอบคะแนน | if (6) 01006012 Computer Programming printf ("Enter your examination points : "); scanf ("%f", &point); printf ("Enter your total points : "); scanf ("%f", &full); if ((point/full) >= 0. 6) { printf ("Name : %s %sn", first, last); printf ("ID : %sn", id); printf ("Examination points : %f / %fn", point, full); printf ("You passed, Congratulationn"); } return 0; } 41
4. 4 การใชคำสง if -else | ภายในเงอนไขมคำสงเดยว 01006012 Computer Programming if (expression) statement-1; else statement-2; 42
4. 4 การใชคำสง if -else | ภายในเงอนไขมหลายคำสง 01006012 Computer Programming if (expression) { statement-1. 1; statement-1. 2; … statement-1. n; } else { statement-2. 1; statement-2. 2; … statement-2. n; } 43
โปรแกรมหารเลข START | if-else (2) 1 01006012 Computer Programming num 1, num 2 != 0 num 1 True False "Error" num 1/num 2 1 END 45
โปรแกรมหารเลข | if -else #include<stdio. h> int main() { float num 1, num 2; printf ("Enter number 1 : scanf ("%f", &num 1); printf ("Enter number 2 : scanf ("%f", &num 2); if (num 2 != 0) printf ("%. 2 f / %. 2 f = else printf ("Error divided return 0; } (3) 01006012 Computer Programming "); %. 2 f", num 1, num 2, num 1/num 2); by zeron"); 46
4. 4 การใชคำสง if -else if | ภายในเงอนไขมคำสงเดยว ลกษณะผกกน 01006012 Computer Programming if (expression-1( statement-1; else if (expression-2) statement-2; . . . else if (expression-m) statement-m; else statement-m+1; 47
การใชคำสง if -else if | ภายในเงอนไขมหลายคำสง 01006012 Computer Programming if (expression-1) { statement-1. 1; . . . statement-1. n; } else if (expression-2) { statement-2. 1; . . . statement-2. n; }. . else if (expression-m) { statement-m. 1; . . . statement-m. n; } else { statement-m+1. 1; . . . statement-m+1. n; } 48
START โปรแกรมตรวจสอบเกรด | if-else if first, last, id, point (5) 01006012 Computer Programming first, last, id, point>=90 True "Grade A" False a b 53
a โปรแกรมตรวจสอบเกรด point>=80 | if-else if True b (6) 01006012 Computer Programming "Grade B" False point>=70 True "Grade C" False point>=60 True "Grade D" False "Grade F" END 54
4. 4 การใชคำสง switch (expression-1) { case constant-expr-1: statement-1. 1; statement-1. 2; . . . statement-1. n; break; case constant-expr-2: statement-2. 1; statement-2. 2; . . . statement-2. n; break; . . . 01006012 Computer Programming. . . case constant-expr-m: statement-m. 1; statement-m. 2; . . . statement-m. n; break; default: statement-d. 1; statement-d. 2; . . . statement-d. n; } 55
การใชคำสง switch | Flowchart 01006012 Computer Programming 56
ตวอยางการใชคำสง switch (1) 01006012 Computer Programming #include<stdio. h> int main () } int d; printf("Enter a number from 1 to 9: "); scanf("%d& , "d ; ( switch (d ( } case 1: puts("A stitch in time saves nine ; (". break ; case 2: case 6: case 9: puts("Handsome is as handsome does ; (". break ; default: puts("Very clever. Try again. "); { return 0; { 57
ตวอยางการใชคำสง switch (2) 01006012 Computer Programming #include<stdio. h> int main () } int d ; printf("Enter a number from 1 to 9 ; (" : scanf("%d& , "d ; ( switch (d ( } case 1: puts("A stitch in time saves nine ; (". break ; case 2: break; case 6: break; case 9: puts("Handsome is as handsome does ; (". break ; default: puts("Very clever. Try again. "); { return 0; { 58
โจทย : โปรแกรมตรวจสอบสถานะการเรยน – ตวอยางการรนโปรแกรม Enter GPA (past) : 0. 74 Your Status : Retired Sorry, Try again. Enter GPA (past) : 1. 50 Your Status : Probation Enter GPS (present) : 2. 00 Enter GPA (present) : 1. 75 Your Status : Probation Enter GPA (past) : 1. 50 Your Status : Probation Enter GPS (present) : 3. 0 Enter GPA (present) : 2. 25 Your Status : Normal (3) 01006012 Computer Programming Enter GPA (past) : 2. 50 Your Status : Normal Enter GPS (present) : 1. 00 Enter GPA (present) : 1. 75 Your Status : Probation Enter GPA (past) : 1. 50 Your Status : Probation Enter GPS (present) : 1. 00 Enter GPA (present) : 1. 25 Your Status : Retired Sorry, Try agin. 61
- Perbedaan linear programming dan integer programming
- Greedy vs dynamic
- System programming vs application programming
- Integer programming vs linear programming
- Perbedaan linear programming dan integer programming
- Nocti computer programming
- μcm
- Concepts, techniques, and models of computer programming
- Language
- Uil computer science programming problems
- Types of variables in computer programming
- Programming raster display system in computer graphics
- Computerite
- Computer programming chapter 1
- Computer aided part programming
- Discrete mathematics with applications susanna s. epp
- Computer programming chapter 1
- Chapter 1 introduction to computers and programming
- Computer programming with matlab
- Four special cases in linear programming
- Decision making in computer programming
- Programming the basic computer
- Fundamentals of computer programming syllabus
- Python programming an introduction to computer science
- Explain the components of computer system
- Difference between a computer and computer system
- Computer, computer basics, input and output devices
- Basic structure of a computer
- Computer organization and architecture difference
- Interrupt cycle flow chart
- Design of basic computer in computer architecture
- Scratch programming logo
- Dts 800 garage door motor
- Gcom 520 login
- Dts gate motor remote
- Excel vba object oriented programming
- Taxonomy of virtualization techniques
- Ruby programming test
- Declarative statement in assembly language
- Computational thinking algorithms and programming
- Pic18 assembly language
- Tiny gals is a programming model for
- Cern programming language
- Extreme programming
- Beta language
- The 8051 has serial port(s)
- Microcontroller assembly language programming
- 2019 virginia tech high school programming contest
- Virginia tech high school programming contest
- 뮤텍스 세마포어
- Echo client server
- What is imperative statement in assembly language
- Suggestive programming
- Stochastic programming
- Generic programming and the stl
- Simplex method example problems with solutions
- Socketaddr_in
- Java client server tutorial
- Socket connection
- Shortest path problem linear programming
- Sic machine architecture
- Canonical form of linear programming problem
- Google translate
- Introduction to server side programming
- Serial communication in 8051 c program